% \iffalse meta-comment
%
% Copyright (C) 2007 by Ignacio Llopis <lloptor@gmail.com>
% -------------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{papertex.dtx}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{papertex}
%<*class>
    [2007/02/27 v1.2a paperTeX class]
%</class>
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs         
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{papertex.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v1.0}{2006/07/06}{Initial version}
% \changes{v1.1}{2007/01/10}{Some minor changes}
% \changes{v1.1a}{2007/01/15}{Changes in documentation}
% \changes{v1.1b}{2007/01/18}{Short news have label. They could not be referenced before. Phantomsections added.}
% \changes{v1.1c}{2007/01/20}{Makeindex removed.}
% \changes{v1.2}{2007/01/25}{New counter minraggedcols and raggedFormat command. They allow users to have ragged texts in news.}
% \changes{v1.2a}{2007/02/27}{Anysize package replaced by geometry. Option `12pt' is now sent to standard article class. Authorandplace aligns on the left now. Bugs in documentation. New `a3paper' option.}
%
% \GetFileInfo{papertex.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
% 
% \newcommand{\blackbox}{\rule{0.65em}{0.65em}} 
%
% \newcommand{\papertex}[0]{paper\TeX{}}
%
%
% \newcommand*{\NEWfeature}[1]{%
%     \hskip 1sp \marginpar{\small\sffamily\raggedright
%     New feature\\#1}}
%
% \title{\papertex{} class: creating newspapers using \LaTeX{}}
%
% \author{Ignacio Llopis \\ \texttt{lloptor@gmail.com}\\{\large Polytechnic University of Valencia}}
%
% \date{Version \fileversion, \filedate}
%
% \maketitle
%
%
% \tableofcontents
%
%
% \section{Introduction} \label{sec:introduction}
%
% \papertex{} class is a \LaTeXe{} class that allows you to create a \papertex{} newspaper. The output document has a front page and as many inner pages as desired. News appear one after another, telling the type, number of columns, heading, subheading, images, author and so forth. It is possible to change the aspect of (almost) everything therefore it is highly customizable. Commands to add different titles, headings and footers are also provided.
%
% This class uses features from many other \LaTeX{} packages and creates new commands and environments to create your own publication. I decided to write my own class because of my language problems using a plain \TeX{} class called |newsletr| by Hunter Goatley. I have used \papertex{} working together with a Perl script that fills the whole \TeX{} source file with database information and compiles the document obtaining a PDF. This process does not require any designer or programmer thus you could use \papertex{} in a  blog or website system.
%
% This manual is typeset according to the conventions of the \LaTeX{} \textsc{docstrip} utility which enables the automatic extraction of the \LaTeX{} macro source files.
%
% Section~\ref{sec:usage} describes the usage of the class.
%
%
%
% \section{Usage} \label{sec:usage}
% To create a \papertex{} newspaper just load the class as usual, with
% \begin{quote}
% |\documentclass|[\textit{class-options}]|{papertex}|
% \end{quote}
% at the beginning of your your \LaTeXe{} source file. The [\textit{class-options}] are as described in section~\ref{sec:options}.
%
% From this point it is possible to include packages and renew class commands described in section~\ref{sec:customization}.
%
%
% \subsection{Front page} \label{ssec:frontpage}
%
% \DescribeEnv{frontpage}
% As every newspaper, \papertex{} has its own front page. It includes main headings, an index, the newspaper logo and other useful information. This environment should be the first you use within \papertex{} class but it is not mandatory, maybe you just want to create a newsletter.
%
%
% \DescribeMacro{\firstimage}\DescribeMacro{\firstnews}
% The first two commands you can use inside the |frontpage| environment are |\firstimage| and |\firstnews| which include, respectively, the main image and the main heading in the front page. The first one takes two arguments \meta{image} and \meta{description}. Notice that second argument is optional and it declares the image caption; \meta{image} defines the relative path to the image. In order to include the first piece of news use
% \begin{quote}
% |\firstnews|\marg{title}\marg{opening}\marg{time}
% \end{quote}
% first two arguments are mandatory and represent the heading and the opening paragraph. Las argument is optional (you can leave it blank) and indicates the time when news happened.
%
%
% \DescribeMacro{\secondnews}
% The second piece of news is included using the command |\secondnews| just as the first news. The main differences are that this second piece has two more arguments and it does not include an image.
% \begin{quote}
% |\secondnews|\marg{title}\marg{subtitle}\marg{opening}\marg{pagesof}\marg{time}
% \end{quote}
% The new arguments \meta{subtitle} and \meta{pagesof} define a subtitle and the name of the section for this piece of news.
%
%
% \DescribeMacro{\thirdnews}
% The third piece of news is the last one in the \papertex{} front page. It works like the |\secondnews| command but it is possible to include an image within the text.
% \begin{quote}
% |\thirdnews|\marg{title}\marg{subtitle}\marg{opening}\parg{image}\marg{pagesof}\marg{time}
% \end{quote}
% Where \meta{image} indicates the relative path to the image. The other arguments meaning is the same as |\secondnews| command.
%
%
% \DescribeEnv{indexblock} \label{env:blocks}
% The front page includes three information blocks besides the news: |indexblock| which contains the index, \DescribeEnv{authorblock} |authorblock| which includes information about the author and a \DescribeEnv{weatherblock} |weatherblock| containing a weather forecast. All these three environments are mostly a frame in the front page therefore they can be redefined to fit your personal wishes but I kept them to give an example and to respect the original \papertex{} format.
%
%
% \DescribeMacro{\indexitem}
% The |indexblock| environment contains a manually edited index of \papertex{}. It takes one optional argument \meta{title} that places a title over the index block. To add entries inside the index just type
% \begin{quote}
% |\indexitem|\marg{title}\marg{reference}
% \end{quote}
% inside the environment. The \meta{title} is the index entry text and the \meta{reference} points to a news inside \papertex{}. It will be more clear when you read subsection~\ref{ssec:inside}. In order to get a correct output, it is necessary to leave a blank line between index items.
%
% The |authorblock| environment can include whatever you would like. I called it |authorblock| because I think it is nice to include some author reference in the front page: who you are, why are you doing this\ldots{} This environment creates a frame box in the bottom right corner of the front page with your own logo at the top.
%
%
% \DescribeMacro{\weatheritem}
% Finally, the |weatherblock| lets you include a weather forecast. It takes one optional argument \meta{title} that places a title over the weather block. It can fit up to three weather icons with maximum and minimum temperatures, description and name. To add each of the weather entries type the following
% \begin{quote}
% |\weatheritem|\parg{image}\marg{day-name}\marg{max}\marg{min}\marg{short-desc}
% \end{quote}
% The first argument indicates the path to the weather icon (i.e. sunny or snow)\footnote{You can download a nice weather icon-set from {\texttt http://www.weather.com}.}, \meta{day-name} like Monday, \meta{max} and \meta{min} are the highest and lowest day temperatures and \meta{short-desc} is a brief description of the weather conditions: partly cloudy, sunny and windy\ldots
%
%
%
% \subsection{Inside} \label{ssec:inside}
%
% Once we have created the front page we should include all news inside our newspaper. \papertex{} arranges all news one after each other, expanding headings all over the page and splitting the news text in the number of columns we wish. There are three different environments to define a piece of news: the |news| environment described in section~\ref{sssec:news}, the |editorial| environment~\ref{sssec:editorial} for opinion news and the |shortnews| environment explained in~\ref{sssec:shortnews}.
%
%
%
% \subsubsection{The news environment} \label{sssec:news}
%
% \DescribeEnv{news}
% The main environment to include a piece of news is called |news|. It takes five arguments that set up the headings and structure of the news.
% \begin{quote}
% |\begin{news}|\marg{num-of-columns}\marg{title}\marg{subtitle}\marg{pagesof}\marg{label}\\
% \ldots \meta{text} \ldots\\
% |\end{news}|
% \end{quote}
% The first argument \meta{num-of-columns} sets the number of columns the news will be divided whereas \meta{label} is used when pointing a news from the index in the front page. The rest of the arguments are easy to understand.
%
% Inside the |news| environment, besides the main text of the news, it is possible to include additional information using several class commands.
%
%
% \DescribeMacro{\authorandplace}
% The |\authorandplace|\marg{author}\marg{place} inserts the name of the editor and the place where the news happened in the way many newspapers do.  \DescribeMacro{\timestamp} Another useful command is |\timestamp|\marg{time} which includes the time and a separator just before the text. These two commands should be used before the text because they type the text at the same place they are executed.
%
%
% \DescribeMacro{\image}
% To include images within the text of a news, \papertex{} provides an |\image| command. Since \texttt{multicol} package does not provide any float support for its |multicol| environment, I created a macro that includes an image only if that is possible, calculating if there is enough space for the image. It is not the best solution but it works quite well and I could not find a better one. To include an image use the command and its two arguments: the relative path to the image and a short description.
% \begin{quote}
% |\image|\parg{image}\marg{description}
% \end{quote}
%
%
% \DescribeMacro{\columntitle} \DescribeMacro{\expandedtitle}
% Within the text of the news, it is possible to add column and expanded titles. The main difference between them is that the first one keeps inside the width of a news column whereas the second expands all over the width of the page, breaking all the columns. Their use is analogous, as follows
% \begin{quote}
% |\columntitle|\marg{type}\marg{text}\\
% |\expandedtitle|\marg{type}\marg{text}
% \end{quote}
% These two commands use \texttt{fancybox} package features. That's why there are five different types of titles which correspond mainly with \texttt{fancybox} ones: |shadowbox|, |doublebox|, |ovalbox|, |Ovalbox| and |lines|.
%
%
%
% \subsubsection{The editorial environment} \label{sssec:editorial}
%
% \DescribeEnv{editorial}
% In addition to the |news| environment, one can use the |editorial| environment to create editorial or opinion texts. The main feature is that it transforms the style of the heading. Although this environment accepts all the commands |news| takes, it does not make any sense to use the |\authorandplace| command within it since it includes an author argument. To create an editorial text use
% \begin{quote}
% |\begin{editorial}|\marg{num-of-columns}\marg{title}\marg{author}\marg{label}\\
% \ldots \meta{text} \ldots\\
% |\end{editorial}|
% \end{quote}
% All arguments have the same meaning as |news| environment (see~\ref{sssec:news}).
%
%
% \subsubsection{The shortnews environment} \label{sssec:shortnews}
%
% \DescribeEnv{shortnews}
% The |shortnews| environment creates a block of short news. Althought it has its own title and subtitle, each piece of news within it may have a title. To use it just type:
% \begin{quote}
% |\begin{shortnews}|\marg{num-of-columns}\marg{title}\marg{subtitle}\marg{label}\\
% \ldots\\
% |\shortnewsitem|\marg{title}\marg{text}\\
% \ldots\\
% |\end{shortnews}|
% \end{quote}
% You can also specify the number of columns of the block like |editorial| and |news| environments. To add a piece of news inside the |shortnews| use the |\shortnewsitem|, indicating a title and the text of the issue.
%
%
% \subsubsection{Commands between news} \label{sssec:between}
%
% \DescribeMacro{\newssep} \DescribeMacro{\newsection}
% There are two commands you can use among the news inside \papertex{}: |\newssep| and |\newsection|. The first one does not take any parameter and just draws a line between two news. The second creates a new PDF bookmark and changes the content of |\papertex@section| to the new \meta{section name}. From the point it is used, all news which follow will be grouped within the new section.
% \begin{quote}
% |\newsection|\marg{section name}
% \end{quote}
%
%
% \section{Customization} \label{sec:customization}
%
% \papertex{} includes many commands which can be used to customize its aspect, from the front page to the last page. I will list them grouped so it is easy to find them. Treat them as standard \LaTeX{} commands, using |\renewcommand| to change their behaviour.
%
%
% \subsection*{Front page}
%
% \DescribeMacro{\logo} \DescribeMacro{\mylogo} \DescribeMacro{\minilogo}
% When creating a newspaper, everyone wants to show its own logo instead of \papertex{} default heading. To achieve this, you can proceed in two different ways: redefining the entire |\logo| command or redefining |\logo| to |\mylogo| which takes one mandatory argument, \meta{whatever}, and keeps the edition name, date and time in the heading space just under \meta{whatever}. You can, for example, insert an image (height up to $1.5 cm$ / $0.6 in$) or some formatted text. Another command relating to your logo is |\minilogo| which defines the small logo that appears inside the |airlock's| (see~\ref{env:blocks}).
%
%
% \DescribeMacro{\edition} \DescribeMacro{\editionFormat}
% The edition text has to be declared in the preamble of the document. One important thing to know is that |\author|, |\date| and |\title| have no effect inside \papertex{} since the newspaper date is taken from |\today| command and the other two are only for the title page (if using |\maketitle|).
%
%
% \DescribeMacro{\indexFormat} \DescribeMacro{\indexEntryFormat} \DescribeMacro{\indexEntryPageTxt} \DescribeMacro{\indexEntryPageFormat} \DescribeMacro{\indexEntrySeparator}
% When defining the index in the front page, there are several commands to customize the final index style. |\indexFormat| sets the format of the title; |\indexEntryFormat|, the format of each index entry; |\indexEntryPageTxt| and |\indexEntryPageFormat| lets you define which is the text that goes with the page number (i.e. page, p., p\'{a}g.) and its format. Finally, \papertex{} creates a thin line between index entries, you can redefine it using |\indexEntrySeparator|. To get the index with |papertex@indexwidth| is provided.
%
%
% \DescribeMacro{\weatherFormat} \DescribeMacro{\weatherTempFormat} \DescribeMacro{\weatherUnits}
% Relating to the weather block, the title format can be changed redefining |\weatherFormat|. In order to customize the format of the temperature numbers and their units it is necessary to redefine |\weatherTempFormat| and |\weatherUnits| respectively.
%
%
% \DescribeMacro{\*TitleFormat} \DescribeMacro{\*SubtitleFormat} \DescribeMacro{\*TextFormat}
% The main news that appear in the front page can change their formats. To obtain that there are three standard commands to modify the title, subtitle and text style. You just have to replace the star (*) with |first|, |second| or |third| depending on which news you are editing. Note that first piece of news has no subtitle therefore it does not make any sense to use the non-existent command |\firstSubtitleFormat|.
%
%
% \DescribeMacro{\pictureCaptionFormat} \DescribeMacro{\pagesFormat}
% Two other elements to configure are the picture captions and the pages or section format in the entire document. To proceed just redefine the macros |\pictureCaptionFormat| and |\pagesFormat|.
%
%
% \subsection*{Inside the newspaper}
%
% \DescribeMacro{\innerTitleFormat} \DescribeMacro{\innerSubtitleFormat} \DescribeMacro{\innerAuthorFormat} \DescribeMacro{\innerPlaceFormat}
% The news inside \papertex{} may have a different format from the ones in the front page. To change their title or subtitle format redefine |\innerTitleFormat| and |\innerSubtitleFormat|. The news text format matches the document general definition. When using the |\authorandplace| command, you might want to change the default style. Just renew |\innerAuthorFormat| and |\innerPlaceFormat| to get the results.
%
%
% \DescribeMacro{\timestampTxt} \DescribeMacro{\timestampSeparator} \DescribeMacro{\timestampFormat}
% The |\timestamp| command described in section~\ref{sssec:news} lets you introduce the time of the event before the news text. You can configure its appearance by altering several commands: |\timestampTxt| which means the text after the timestamp (i.e. h., hours, secs.); |\timestampSeparator| which defines the element between the actual timestamp and the beginning of the text and, finally, |\timestampFormat| to change the entire timestamp format.
%
%
% \DescribeMacro{\innerTextFinalMark}
% Most of the newspaper in my country (Spain) finish the news text with a black square (\blackbox{}). As I wanted to create a highly customizable \LaTeX{} class I added the macro |\innerTextFinalMark| to change this black square. This item will appear always following the last character of the text with the $\sim$ character.
%
%
% \DescribeMacro{\minraggedcols} \DescribeMacro{\raggedFormat}
% \NEWfeature{v1.2}
% The |\minraggedcols| counter is used to tell \papertex{} when news text should be ragged instead of justified. 
% The counter represents the minimum number of columns that are needed in order to use ragged texts. For example, 
%if |\minraggedcols| is set to $3$, all news with $3$ columns or more will be ragged. 
% News with $1$, $2$ columns will have justified text. 
% By default, |\minraggedcols| is set to $4$.
%
% The |\raggedFormat| macro can be redefined to fit user ragged style. Default value is |\RaggedRight|.
%
%
% \DescribeMacro{\heading} \DescribeMacro{\foot}
% \papertex{} includes package \texttt{fancyhdr} for changing headings and footers. Although it is possible to use its own commands to modify \papertex{} style, there are two commands to change headings and foot appearance. Place them in the preamble of your \papertex{} document.
% \begin{quote}
% |\heading|\marg{left}\marg{center}\marg{right}
%
% |\foot|\marg{left}\marg{center}\marg{right}
% \end{quote}
%
% If you still prefer to use fancyhdr macros, use them after the |frontpage| environment.
%
%
%
% \section{Class options} \label{sec:options}
%
% The \papertex{} class is in itself an alteration of the standard \texttt{article} class, thus it inherits most of its class options but |twoside|, |twocolumn|, |notitlepage| and |a4paper|. If you find problems when loading other \texttt{article} features, please let me know to fix it.
%
% There are also five own options that \papertex{} implements.\\
% \NEWfeature{v1.2a}
% \begin{description}
% \item[a3paper] (\textit{false}) This option makes \papertex{} $297mm$ width by $420mm$ height. This option is implemented because the standard \texttt{article} class does not allow this document size.
% \item[9pt] (\textit{false}) Allows the $9pt$ font size that \texttt{article} class does not include (default is $10pt$).
% \item[hyphenatedtitles] (\textit{false}) Forces heading titles to be hyphenated. This feature is off by default because most of newspapers prefer not to hyphenate them.
% \item[columnlines] (\textit{false}) Adds lines between columns in the entire \papertex{}. The default line width is $0.1pt$ but it is possible to change this by setting length |\columnlines| in the preamble.
% \item[showgrid] (\textit{false}) This option is only for developing purposes. Because the front page has a personal design using the \texttt{textpos} package, I created this grid to make easier the lay out.
% \end{description}
%
%
% \section{Implementation}
% This section deals with the package source code. Please, do not read this unless you really need it. The comments are very short and they, generally, just tell you where you are. If you are experiencing any problems when testing this class, you could send me an email and I would try to solve it.
%
% Of course, I am also pleased to receive emails telling me what is wrong in this code or what I should improve. It would be great!
%
% \subsection{Init, packages and options}
%
%
% First define \papertex{} class.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{papertex}[2006/07/06 paperTeX class]
%    \end{macrocode}
%
% Require \texttt{ifthen} package which will be very useful.
%    \begin{macrocode}
\RequirePackage{ifthen}
%    \end{macrocode}
%
% Define some lengths for page sizes.
%    \begin{macrocode}
\newlength{\papertex@imgsize}
\newlength{\papertex@coltitsize}
\newlength{\papertex@pageneed}
\newlength{\papertex@pageleft}
\newlength{\papertex@indexwidth}
%    \end{macrocode}
%
% Keep track of the number of columns of the piece of news we are in.
%    \begin{macrocode}
\newcommand{\papertex@ncolumns}{0}
%    \end{macrocode}
%
% Lines between columns. This is a \texttt{multicol} package feature.
%    \begin{macrocode}
\newlength{\columnlines}
\setlength{\columnlines}{0 pt} % no lines by default
%    \end{macrocode}
%
% Define some booleans to control \papertex{} class options like hyphenated titles
% in front page, nine points font or front page grid.
%    \begin{macrocode}
\newboolean{papertex@hyphenatedtitles}
\setboolean{papertex@hyphenatedtitles}{true}
\newboolean{papertex@ninepoints}
\setboolean{papertex@ninepoints}{false}
\newboolean{papertex@showgrid}
\setboolean{papertex@showgrid}{false}
\newboolean{papertex@a3paper}
\setboolean{papertex@a3paper}{false}
%    \end{macrocode}
%
% Some booleans to keep track of where we are.
%    \begin{macrocode}
\newboolean{papertex@insidefrontpage}
\setboolean{papertex@insidefrontpage}{false}
\newboolean{papertex@insideweather}
\setboolean{papertex@insideweather}{false}
\newboolean{papertex@insideindex}
\setboolean{papertex@insideindex}{false}
%    \end{macrocode}
%
% These counters are needed for creating the front page virtual grid
% which comes from the \textit{absolute} option of the \texttt{textpos} package.
%    \begin{macrocode}
\newcount\papertex@gridrows
\newcount\papertex@gridcolumns
\papertex@gridrows=40
\papertex@gridcolumns=50
%    \end{macrocode}
%
% \NEWfeature{v1.2}
% The following count defines when \papertex{} should use ragged text instead 
% of justified text. It represents the maximum number of columns not ragged. 
% Default value is $5$.
%    \begin{macrocode}
\newcount\minraggedcols
\minraggedcols=5
%    \end{macrocode}
%
% Now, we declare the class options.
% First, all the options which \papertex{} inherits from ``article.cls'' standard class.
%    \begin{macrocode}
\DeclareOption{10pt}{\PassOptionsToClass{10pt}{article}}
\DeclareOption{11pt}{\PassOptionsToClass{11pt}{article}}
\DeclareOption{12pt}{\PassOptionsToClass{12pt}{article}}
%    \end{macrocode}
%
% Second, options \papertex{} does not inherit from ``article.cls''.
%    \begin{macrocode}
\DeclareOption{twocolumn}%
	{\ClassWarning{paperTeX}{Option 'twocolumn' not available for paperTeX.}}
\DeclareOption{notitlepage}%
	{\ClassWarning{paperTeX}{Option 'notitlepage' not available for paperTeX.}}
\DeclareOption{twoside}%
	{\ClassWarning{paperTeX}{Option 'twoside' not available for paperTeX.}}
%    \end{macrocode}
%
% Finally, \papertex{} own options.
%    \begin{macrocode}
\DeclareOption{9pt}{\setboolean{papertex@ninepoints}{true}}
\DeclareOption{hyphenatedtitles}{\setboolean{papertex@hyphenatedtitles}{false}}
\DeclareOption{columnlines}{\setlength{\columnlines}{0.1 pt}}
\DeclareOption{showgrid}{\setboolean{papertex@showgrid}{true}}
\DeclareOption{a3paper}{\setboolean{papertex@a3paper}{true}}
%    \end{macrocode}
%
% As \papertex{} is based in the \LaTeX{} ``article'' class,
% we load this class with default \papertex{} options.
%    \begin{macrocode}
\ProcessOptions\relax
\LoadClass[10pt, onecolumn, titlepage, a4paper]{article}
%    \end{macrocode}
%
% From this point, \papertex{} requires all packages needed.
%    \begin{macrocode}
\RequirePackage{ifpdf}
\RequirePackage{multido}
\RequirePackage{datetime}
\RequirePackage{multicol}
\RequirePackage{fancyhdr}
\RequirePackage{fancybox}
%    \end{macrocode}
%
% \NEWfeature{v1.2a}
% Define margins using \texttt{geometry} package to get as much as possible from the page layout. It is also time to check if ``a3paper'' option is requested.
%    \begin{macrocode}
\ifthenelse{\boolean{papertex@a3paper}}{%
	\RequirePackage[a3paper,headsep=0.5cm,vmargin={2cm,2cm},hmargin={1.5cm,1.5cm}]{geometry}
}{
	\RequirePackage[headsep=0.5cm,vmargin={2cm,2cm},hmargin={1.5cm,1.5cm}]{geometry}
}
%    \end{macrocode}
%
% Some requirements whether we compile using PDF\LaTeX{} or just \LaTeX{}.
%    \begin{macrocode}
\ifpdf
	\RequirePackage[pdftex]{graphicx,color}
 	\RequirePackage[pdftex]{hyperref}
\else
	\RequirePackage{color}
	\RequirePackage[dvips]{graphicx}
	\RequirePackage[dvips]{hyperref}
\fi
%    \end{macrocode}
%
% Some more packages\ldots
%    \begin{macrocode}
\RequirePackage[absolute]{textpos} % absoulte positioning
\RequirePackage{hyphenat} % when hyphenate
\RequirePackage{wrapfig}
\RequirePackage{lastpage} % to know the last page number
\RequirePackage{setspace} % set space between lines
%    \end{macrocode}
%
% \NEWfeature{2007/01/25}
% We, now, load \texttt{ragged2e} package in order to provide \papertex{} with 
% nicely ragged texts. A new command called  |\raggedFormat| is defined to control 
% which kind of ragged format should be used.
%    \begin{macrocode}
\RequirePackage{ragged2e}
\newcommand{\raggedFormat}{\RaggedRight}
%    \end{macrocode}
%
% When the whole class is loaded, draw the front page grid. Draw lines if requested by using \textbf{showgrid} option. 
% There is also a substraction from |\minraggedcols| counter by one in order to match is definition.
%    \begin{macrocode}
\AtEndOfClass{\papertexInit}
\ifthenelse{\boolean{papertex@showgrid}}{%
	\AtBeginDocument{
		\grid[show]{\papertex@gridrows}{\papertex@gridcolumns}}
		\advance\minraggedcols by -1
	}{%
	\AtBeginDocument{
		\grid[]{\papertex@gridrows}{\papertex@gridcolumns}}
		\advance\minraggedcols by -1
	}
%    \end{macrocode}
%
% Definition of \textbf{ninepoints} class option.
%    \begin{macrocode}
\ifthenelse{\boolean{papertex@ninepoints}}{
	\renewcommand{\normalsize}{%
	  \@setfontsize{\normalsize}{9pt}{10pt}%
	  \setlength{\abovedisplayskip}{5pt plus 1pt minus .5pt}%
	  \setlength{\belowdisplayskip}{\abovedisplayskip}%
	  \setlength{\abovedisplayshortskip}{3pt plus 1pt minus 2pt}%
	  \setlength{\belowdisplayshortskip}{\abovedisplayshortskip}}
	
	\renewcommand{\tiny}{\@setfontsize{\tiny}{5pt}{6pt}}
	
	\renewcommand{\scriptsize}{\@setfontsize{\scriptsize}{7pt}{8pt}}
	
	\renewcommand{\small}{%
	  \@setfontsize{\small}{8pt}{9pt}%
	  \setlength{\abovedisplayskip}{4pt plus 1pt minus 1pt}%
	  \setlength{\belowdisplayskip}{\abovedisplayskip}%
	  \setlength{\abovedisplayshortskip}{2pt plus 1pt}%
	  \setlength{\belowdisplayshortskip}{\abovedisplayshortskip}}
	
	\renewcommand{\footnotesize}{%
	  \@setfontsize{\footnotesize}{8pt}{9pt}%
	  \setlength{\abovedisplayskip}{4pt plus 1pt minus .5pt}%
	  \setlength{\belowdisplayskip}{\abovedisplayskip}%
	  \setlength{\abovedisplayshortskip}{2pt plus 1pt}%
	  \setlength{\belowdisplayshortskip}{\abovedisplayshortskip}}
	
	\renewcommand{\large}{\@setfontsize{\large}{11pt}{13pt}}
	\renewcommand{\Large}{\@setfontsize{\Large}{14pt}{18pt}}
	\renewcommand{\LARGE}{\@setfontsize{\LARGE}{18pt}{20pt}}
	\renewcommand{\huge}{\@setfontsize{\huge}{20pt}{25pt}}
	\renewcommand{\Huge}{\@setfontsize{\Huge}{25pt}{30pt}}
}{}
%    \end{macrocode}
%
%
%
% \subsection{\papertex{} default style}
%
%
% Colours.
%    \begin{macrocode}
\definecolor{color}{cmyk}{0.5, 0, 1, 0.5}
\definecolor{max}{cmyk}{0, 0.5, 0.5, 0.5}
\definecolor{min}{cmyk}{0.5, 0, 0.5, 0.5}
%    \end{macrocode}
%
% Web address.
%    \begin{macrocode}
\newcommand{\papertex@wwwTxt}{http://nachollopis.com}
\newcommand{\papertex@wwwFormat}{\sffamily}
\newcommand{\papertex@www}{%
	\raisebox{-3pt}{{\papertex@wwwFormat\papertex@wwwTxt}}
}
%    \end{macrocode}
%
% Edition.
%    \begin{macrocode}
\newcommand{\papertex@edition}{MY EDITION}
\newcommand{\editionFormat}{\large\bfseries\texttt}
\newcommand{\papertex@editionLogo}{%
	\raisebox{-3pt}{%
		\textcolor{color}{{\editionFormat\papertex@edition}}%
	}%
}
%    \end{macrocode}
%
% Index.
%    \begin{macrocode}
\newcommand{\indexFormat}{\large\bfseries\sffamily}
\newcommand{\papertex@indexFrameTitle}[1]
	{\begin{flushright}{\textcolor{color}{{\indexFormat #1}}}\end{flushright}}

\newcommand{\indexEntryFormat}{\large\sffamily}
\newcommand{\papertex@indexEntry}[1]{\begin{minipage}{13\TPHorizModule}%
												{\indexEntryFormat\noindent\ignorespaces{#1}}%
												\end{minipage}}
\newcommand{\indexEntrySeparator}{\rule{\papertex@indexwidth}{.1pt}}
\newcommand{\indexEntryPageTxt}{p.}
\newcommand{\indexEntryPageFormat}{\footnotesize}
\newcommand{\papertex@indexEntryPage}[1]{%
	{\indexEntryPageFormat\textcolor{color}{\indexEntryPageTxt{}~#1}}%
}
%    \end{macrocode}
%
% Date and time.
%    \begin{macrocode}
\newcommand{\headDateTimeFormat}{}
\newcommand{\papertex@headDateTime}{%
	\headDateTimeFormat\date\hspace{5pt}$\parallel$\hspace{5pt}%
	\textcolor{color}{\currenttime h}%
}
%    \end{macrocode}
%
% Weather.
%    \begin{macrocode}
\newcommand{\weatherFormat}{\bfseries\sffamily}
\newcommand{\papertex@weather}[1]{%
	\noindent\textcolor{color}{{\weatherFormat #1}}%
}
\newcommand{\weatherTempFormat}{\small}
\newcommand{\weatherUnits}{\textdegree{}C}
%    \end{macrocode}
%
% Section name.
%    \begin{macrocode}
\newcommand{\papertex@section}[0]{FRONT PAGE}
%    \end{macrocode}
%
% Inner pages heading.
%    \begin{macrocode}
\newcommand{\papertex@headleft}{%
	{{\usefont{T1}{bch}{b}{n} \noindent\textcolor{color}{paper}}%
	{\usefont{T1}{pag}{m}{n} \textcolor{black}{TeX}} , \date}%
}
\newcommand{\papertex@headcenter}{%
	\papertex@section{}
}
\newcommand{\papertex@headright}{%
	\textcolor{color}{\small\papertex@edition}%
	\hspace*{5pt}\thepage\ / \pageref{LastPage}
}

\newcommand{\heading}[3]{%
	\renewcommand{\papertex@headleft}{#1}%
	\renewcommand{\papertex@headcenter}{#2}%
	\renewcommand{\papertex@headright}{#3}%
}
%    \end{macrocode}
%
% Inner pages foot.
%    \begin{macrocode}
\newcommand{\papertex@footleft}{%
	{\footnotesize\copyright\ \papertex@wwwTxt{} - Created using paper\TeX{}}%
}
\newcommand{\papertex@footcenter}{%
}
\newcommand{\papertex@footright}{%
}

\newcommand{\foot}[3]{%
	\renewcommand{\papertex@footleft}{#1}%
	\renewcommand{\papertex@footcenter}{#2}%
	\renewcommand{\papertex@footright}{#3}%
}
%    \end{macrocode}
%
% First news on main page.
%    \begin{macrocode}
\newcommand{\firstTitleFormat}{\Huge\sffamily\bfseries\flushleft}
\newcommand{\papertex@firstTitle}[1]{%
	{%
		\begin{spacing}{2.0}{%
			\noindent\ignorespaces
			\ifthenelse{\boolean{papertex@hyphenatedtitles}}%
			{\nohyphens{\firstTitleFormat #1}}%
			{{\firstTitleFormat #1}}%
		}%
		\end{spacing}%
	}%
}
\newcommand{\firstTextFormat}{}
\newcommand{\papertex@firstText}[1]{%
	{\noindent\ignorespaces\firstTextFormat #1}%
}
%    \end{macrocode}
%
% Second news on main page.
%    \begin{macrocode}
\newcommand{\secondTitleFormat}{\LARGE\sffamily\bfseries}
\newcommand{\papertex@secondTitle}[1]{%
	\begin{spacing}{1.5}{%
		\noindent\ignorespaces\flushleft
		\ifthenelse{\boolean{papertex@hyphenatedtitles}}%
		{\nohyphens{\secondTitleFormat #1}}%
		{{\secondTitleFormat #1}}%
	}\end{spacing}%
}
\newcommand{\secondSubtitleFormat}{\large}
\newcommand{\papertex@secondSubtitle}[1]{%
	{\noindent\ignorespaces{\secondSubtitleFormat #1}}%
}
\newcommand{\secondTextFormat}{}
\newcommand{\papertex@secondText}[1]{%
	\begin{multicols}{2}
		{\noindent\ignorespaces\secondTextFormat #1}
	\end{multicols}
}
%    \end{macrocode}
%
% Third news on main page.
%    \begin{macrocode}
\newcommand{\thirdTitleFormat}{\Large\sffamily\bfseries}
\newcommand{\papertex@thirdTitle}[1]{%
	\begin{spacing}{1.5}{%
		\noindent\ignorespaces\flushleft
		\ifthenelse{\boolean{papertex@hyphenatedtitles}}%
		{\nohyphens{\thirdTitleFormat #1}}%
		{{\thirdTitleFormat #1}}%
	}\end{spacing}%
}
\newcommand{\thirdSubtitleFormat}{\large}
\newcommand{\papertex@thirdSubtitle}[1]%
	{{\noindent\ignorespaces\thirdSubtitleFormat #1}}
\newcommand{\thirdTextFormat}{}
\newcommand{\papertex@thirdText}[1]{{\thirdTextFormat #1}}
%    \end{macrocode}
%
% Pictures captions.
%    \begin{macrocode}
\newcommand{\pictureCaptionFormat}{\small\bfseries}
\newcommand{\papertex@pictureCaption}[1]{%
	{\noindent\pictureCaptionFormat #1}%
}
%    \end{macrocode}
%
% Pages: \papertex{} sections.
%    \begin{macrocode}
\newcommand{\pagesFormat}{\bfseries\footnotesize}
\newcommand{\papertex@pages}[1]%
	{\noindent\textcolor{color}{\pagesFormat\MakeUppercase{#1}}}
%    \end{macrocode}
%
% Inner pages news: \texttt{normal} style.
% \begin{itemize}
% \item Heading.
%    \begin{macrocode}
\newcommand{\innerTitleFormat}{\Huge}
\newcommand{\papertex@innerTitle}[1]{%
	\begin{flushleft}{%
		\noindent
		\ifthenelse{\boolean{papertex@hyphenatedtitles}}%
		{\nohyphens{\innerTitleFormat #1}}%
		{{\innerTitleFormat #1}}%
	}%
	\\%
	\end{flushleft}%
}
%    \end{macrocode}
%
% \item Subheading.
%    \begin{macrocode}
\newcommand{\innerSubtitleFormat}{\large}
\newcommand{\papertex@innerSubtitle}[1]{{\innerSubtitleFormat #1}}
%    \end{macrocode}
%
% \item Time.
%    \begin{macrocode}
\newcommand{\timestampTxt}{h}
\newcommand{\timestampSeparator}{|}
\newcommand{\timestampFormat}{\small}
\newcommand{\timestamp}[1]{%
	{\timestampFormat\textcolor{color}{%
		#1~\timestampTxt{}}%
	}~\timestampSeparator{}%
}
%    \end{macrocode}
%
% \item Author.
%    \begin{macrocode}
\newcommand{\innerAuthorFormat}{\footnotesize}
%    \end{macrocode}
%
% \item Place.
%    \begin{macrocode}
\newcommand{\innerPlaceFormat}{\footnotesize\bfseries}
%    \end{macrocode}
%
% \item Section. See |\sectionFormat|.
% \item Image caption. See |\pictureCaptionFormat|.
%
% \item Final text mark. A black square.
%    \begin{macrocode}
\newcommand{\innerTextFinalMark}{\rule{0.65em}{0.65em}} 
%    \end{macrocode}
%
% \end{itemize}
%
% Inner pages news: \texttt{editorial} (opinion) style.
% \begin{itemize}
% \item Heading.
%    \begin{macrocode}
\newcommand{\editorialTitleFormat}{\LARGE\textit}
\newcommand{\papertex@editorialTitle}[1]{\editorialTitleFormat{#1}}
%    \end{macrocode}
%
% \item Author.
%    \begin{macrocode}
\newcommand{\editorialAuthorFormat}{\textsc}
%    \end{macrocode}
%
% \end{itemize}
%
%
% Inner pages news: \texttt{shortnews} style.
% \begin{itemize}
% \item Group heading.
%    \begin{macrocode}
\newcommand{\shortnewsTitleFormat}{\LARGE\bfseries}
\newcommand{\papertex@shortnewsTitle}[1]{{\shortnewsTitleFormat #1}}
%    \end{macrocode}
%
% \item Group subheading.
%    \begin{macrocode}
\newcommand{\shortnewsSubtitleFormat}{\Large}
\newcommand{\papertex@shortnewsSubtitle}[1]{{\shortnewsSubtitleFormat #1}}
%    \end{macrocode}
%
% \item Sigle item heading.
%    \begin{macrocode}
\newcommand{\shortnewsItemTitleFormat}{\large\bfseries}
\newcommand{\papertex@shortnewsItemTitle}[1]{{\shortnewsItemTitleFormat #1}}
%    \end{macrocode}
%
% \end{itemize}
%
%
% \subsection{General macros}
%
% First, we have a little hack to |\maketitle| \texttt{article} macro.
%    \begin{macrocode}
\renewcommand{\maketitle}{\begin{titlepage}%
  \let\footnotesize\small
  \let\footnoterule\relax
  \let \footnote \thanks
  \null\vfil
  \vskip 60\p@
  \begin{center}%
    {\LARGE \@title \par}%
    \vskip 1em%
    {\LARGE ``\papertex@edition '' \par}%
    \vskip 3em%
    {\large
     \lineskip .75em%
      \begin{tabular}[t]{c}%
        \@author
      \end{tabular}\par}%
      \vskip 1.5em%
    {\large \@date \par}%
  \end{center}\par
  \@thanks
  \vfil\null
  \end{titlepage}%
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}
%    \end{macrocode}
%
%
% Prints out some text when compiling.
%    \begin{macrocode}
\newcommand{\papertex@say}[1]{\typeout{#1}}
%    \end{macrocode}
%
%
% Minipage inside a framebox.
%    \begin{macrocode}
\newsavebox{\papertex@fmbox}
\newenvironment{papertex@fmpage}[1]
 {\begin{lrbox}{\papertex@fmbox}\begin{minipage}{#1}}
 {\end{minipage}\end{lrbox}\fbox{\usebox{\papertex@fmbox}}} 
%    \end{macrocode}
% 
%
% Next macro inserts an image inside a \textit{news} environment. The image is resized in order
% to fit in the column width. The image is also surrounded by a frame.
% This macro controls that there is enough space to include the image otherwise
% it shows a warning in the compilation log.
%    \begin{macrocode}
\newcommand{\image}[2]{
	\vspace{5pt}
	%distance between frame and image
	\setlength{\fboxsep}{1pt}
	%new image size
	\addtolength{\papertex@imgsize}{\columnwidth}
	%substract space between columns
	\addtolength{\papertex@imgsize}{-1\columnsep}
	\ifpdf
		\setlength{\papertex@pageneed}{1.5\papertex@imgsize}
		\addtolength{\papertex@pageneed}{50pt}
		\ClassWarning{paperTeX}{%
			Image #1 needs: \the\papertex@pageneed \space %
			and there is left: \the\page@free\space%
		}
		%image fits in
		\ifdim \papertex@pageneed < \page@free
			
			{\centering\fbox{%
				\includegraphics[width = \papertex@imgsize,
										height = \papertex@imgsize,
										keepaspectratio ]{#1}}}
			\papertex@pictureCaption{#2}
			
			\vspace{5pt}
		\else
			%not enough space
			\ClassWarning{Image #1 needs more space!%
								  It was not inserted!}
		\fi
	\fi
}
%    \end{macrocode}
%
% Some \texttt{textpos} parameters in order to start everything from the upper left corner. 
%    \begin{macrocode}
\textblockorigin{1cm}{1cm}
%    \end{macrocode}
%
% Some \texttt{textpos} dimensions to draw the invisible grid.
%    \begin{macrocode}
\newdimen\papertex@dx
\newdimen\papertex@dy
\newcount\papertex@cx
\newcount\papertex@cy
%    \end{macrocode}
%
% This command draws the grid we need to place everything in the front page at absolute positions. 
% If first optional argument is set to ``show'', lines are shown so you can see the grid.
%    \begin{macrocode}
\newcommand{\grid}[3][]{
	\papertex@dx=\textwidth%
	\papertex@dy=\textheight%
	\papertex@cx=#3% %columns
	\papertex@cy=#2% %rows
	
	\count1=#3%
	\advance\count1 by 1
	
	\count2=#2%
	\advance\count2 by 1
	
	%calculate cell dimensions
	\divide\papertex@dx by #3
	\divide\papertex@dy by #2

	\setlength{\TPHorizModule}{\papertex@dx}
	\setlength{\TPVertModule}{\papertex@dy}
	
	\ifthenelse{\equal{#1}{show}}{
		%draw rows
		\multido{\papertex@nrow=0+1}{\count2}{
			\begin{textblock}{\papertex@cx}(0,\papertex@nrow)
				\rule[0pt]{\textwidth}{.1pt}
			\end{textblock}
		}
		
		%draw columns
		\multido{\papertex@ncol=0+1}{\count1}{
			\begin{textblock}{\papertex@cy}(\papertex@ncol,0)
				\rule[0pt]{.1pt}{\textheight}
			\end{textblock}
		}
	}{}	
}
%    \end{macrocode}
%
%
% This macro inits \papertex{}: heading size, page style, space between columns and frame box line width.
% It also creates the index using \texttt{makeindex}.
%
%    \begin{macrocode}
\newcommand{\papertexInit}{
	\setlength{\headheight}{14pt}
	\renewcommand{\headrulewidth}{0.4pt}

	\pagestyle{fancy}
	
	\setlength{\columnseprule}{\columnlines} 
	\setlength{\fboxrule}{0.1 pt}
	
}	
%    \end{macrocode}
%
%
\newcommand{\logo}[0]{
	%% Heading %%
	\noindent\hrulefill\hspace{10pt}\papertex@editionLogo\hspace{5pt}\papertex@www
	
	\vspace*{-3pt}
	
	{\fontsize{10mm}{12mm} \usefont{T1}{bch}{b}{n} \noindent\textcolor{color}{\sffamily paper}}%
	{\fontsize{12mm}{14mm} \usefont{T1}{pag}{m}{n} \textcolor{black}{TeX}}
	%
	\hrulefill
	\hspace{10pt}\papertex@headDateTime
	
}
%
\newcommand{\minilogo}[0]{
	{\fontsize{4mm}{6mm} \usefont{T1}{bch}{b}{n} \noindent\textcolor{color}{\sffamily paper}}%
	{\fontsize{7mm}{12mm} \usefont{T1}{pag}{m}{n} \textcolor{black}{TeX}}
	
	\vspace*{5pt}
}
%
% The |\mylogo| macro can be redefined in order to use a customized head image.
%
%    \begin{macrocode}
\newcommand{\mylogo}[1]{
	{#1}
	
	\noindent
	\papertex@editionLogo\hspace{5pt}
	\hrulefill
	\hspace{5pt}\papertex@headDateTime
}
%    \end{macrocode}
%
% Edition command.
%
%    \begin{macrocode}
\newcommand{\edition}[1]{\renewcommand{\papertex@edition}{#1}}
%    \end{macrocode}
%
% Next environment surrounds newspaper front page. It defines 
% its own style (heading and foot) and keeps track of where we are.
%    \begin{macrocode}
\newenvironment{frontpage}[0]
{
	\setboolean{papertex@insidefrontpage}{true}
	\thispagestyle{empty}
	\pdfbookmark[1]{FRONT PAGE}{\thepage}
	\logo
	
}%
{
	\thispagestyle{empty}
	\clearpage
	\newpage
	
	
	\fancyhead{}
	\fancyfoot{}
	\fancyhead[R]{\papertex@headright}
	\fancyhead[L]{\papertex@headleft}
    \fancyhead[C]{\papertex@headcenter}
    \fancyfoot[R]{\papertex@footright}
    \fancyfoot[L]{\papertex@footleft}
	\fancyfoot[C]{\papertex@footcenter}
	\renewcommand{\headrulewidth}{0.4pt}
	\setboolean{papertex@insidefrontpage}{false}
	%
	
}
%    \end{macrocode}
%
%
%
% \subsection{Front page}
% Edit these items to set up your own front page
% Read \texttt{textpos} documentation to know how to work
% with textblocks.
% Don't forget to use \papertex{} styles for titles, captions
% and so on. It will be more consistent.
%
% First piece of news.
%
%    \begin{macrocode}
\newcommand{\firstnews}[3]
{
	\ifthenelse{\boolean{papertex@insidefrontpage}}{%
		\ifthenelse{\boolean{papertex@hyphenatedtitles}}{%
			\begin{textblock}{24}(22,5)
		}
		{
			\begin{textblock}{28}(22,5)
		}
			\vspace{-7pt}
			\papertex@firstTitle{#1}
		\end{textblock}
		\begin{textblock}{29}(22,10)
			\vspace{5pt plus 2pt minus 2pt}
	
			\papertex@firstText{\timestamp{#3}~#2}
			
		\end{textblock}
		
		\begin{textblock}{50}(0,15)
			\rule{50\TPHorizModule}{.3pt}
		\end{textblock}
	}{%else
		\ClassError{paperTeX}{%
			\protect\firstnews\space in a wrong place.\MessageBreak
			\protect\firstnews\space may only appear inside frontpage environment.
		}{%
			\protect\firstnews\space may only appear inside frontpage environment.
		}%
	}
}
%    \end{macrocode}
%
%
%
% Second piece of news.
%
%    \begin{macrocode}
\newcommand{\secondnews}[5]
{
	\ifthenelse{\boolean{papertex@insidefrontpage}}{%
		\begin{textblock}{33}(2,16)
			\papertex@pages{#4}
			\vspace{-5pt}
			\papertex@secondTitle{#1}
		
			\vspace*{5pt}
			
			\papertex@secondSubtitle{#2}
			
			\vspace*{-7pt}
			
			\papertex@secondText{\timestamp{#5}~#3}
			
		\end{textblock}
		
		\begin{textblock}{33}(2,25)
			\vspace{5pt plus 2pt minus 2pt}
	
			\noindent\ignorespaces\rule{33\TPHorizModule}{.3pt}
		\end{textblock}
	}{%else
		\ClassError{paperTeX}{%
			\protect\secondnews\space in a wrong place.\MessageBreak
			\protect\secondnews\space may only appear inside frontpage environment.
		}{%
			\protect\secondnews\space may only appear inside frontpage environment.
		}%
	}
}
%    \end{macrocode}
%
%
% Third piece of news. It is possible to avoid using an image just leaving the 4th parameter empty.
%
%    \begin{macrocode}
\newcommand{\thirdnews}[6]
{
	\ifthenelse{\boolean{papertex@insidefrontpage}}{%
		\begin{textblock}{32}(2,26)
			\papertex@pages{#5}
			\vspace{-5pt}
			\setlength{\fboxsep}{1pt}
			\papertex@thirdTitle{#1}
			
			\vspace*{5pt}
			
			\papertex@thirdSubtitle{#2}
			
			\vspace*{5pt}
			
			{\noindent\ignorespaces %
			\ifthenelse{\equal{#4}{}}{}
				{\begin{wrapfigure}{r}{.3\textwidth}
				\vspace*{-12pt}
				\ifpdf
				\noindent\fbox{\includegraphics[width=.3\textwidth]{#4}}
				\fi
				\end{wrapfigure}%
				}%
			\papertex@thirdText{\timestamp{#6}~#3}
			
			}
	
			\vspace*{5pt}
			
		\end{textblock}
	}{%else
		\ClassError{paperTeX}{%
			\protect\thirdnews\space in a wrong place.\MessageBreak
			\protect\thirdnews\space may only appear inside frontpage environment.
		}{%
			\protect\thirdnews\space may only appear inside frontpage environment.
		}%
	}
}
%    \end{macrocode}
%
%
%	Main image in front page. Usually related to |\firstNews|.
%
%    \begin{macrocode}
\newcommand{\firstimage}[2]
{
	\ifthenelse{\boolean{papertex@insidefrontpage}}{%
	\begin{textblock}{18}(2,5)
		\setlength{\fboxsep}{1pt}
		\ifpdf % only in PDF
		\noindent\fbox{\includegraphics[width = 18\TPHorizModule ]{#1}}
		\fi
		
		\papertex@pictureCaption{#2}
	\end{textblock}%
	}
	{\ClassError{paperTeX}{%
			\protect\firstimage\space in a wrong place.\MessageBreak
			\protect\firstimage\space may only appear inside frontpage environment.
		}{%
			\protect\firstimage\space may only appear inside frontpage environment.
	}}
}%
%    \end{macrocode}
%
%
% Weather item (weather forecast).
%
%    \begin{macrocode}
\newcommand{\weatheritem}[5]{%
	\ifthenelse{\boolean{papertex@insideweather}}{
		\begin{minipage}{45pt}
			\ifpdf
			\includegraphics[width=40pt]{#1}
			\fi
		\end{minipage}
		\begin{minipage}{50pt}
			\weatherTempFormat
			#2\\	
			\textcolor{min}{#3} $\|$ \textcolor{max}{#4} \weatherUnits{}\\
			#5
		\end{minipage}
	}{%else
		\ClassError{paperTeX}{%
			\protect\weatheritem\space in a wrong place.\MessageBreak
			\protect\weatheritem\space may only appear inside weatherblock environment.
		}{%
			\protect\weatheritem\space may only appear inside weatherblock environment.\MessageBreak
			weatherblock environment may only appear inside frontpage environment.
		}%
	}
}
%    \end{macrocode}
%
%
% Weather block.
%
%    \begin{macrocode}
\newenvironment{weatherblock}[1]
{
	\ifthenelse{\boolean{papertex@insidefrontpage}}{%
		\setboolean{papertex@insideweather}{true}
		\begin{textblock}{32}(2,38)
		\vspace*{-15pt}
		
		\hfill\papertex@weather{#1}
		
		\vspace*{5pt}
		
		\noindent\begin{papertex@fmpage}{32\TPHorizModule}
			\begin{minipage}{32\TPHorizModule}
				\hspace{5pt}		
	
	}{%
		\ClassError{paperTeX}{%
			weatherblock in a wrong place.\MessageBreak
			weatherblock may only appear inside frontpage environment.
		}{%
			weatherblock may only appear inside frontpage environment.
		}
	}
}%
{	
			\end{minipage}
			\end{papertex@fmpage}
		\end{textblock}
		\setboolean{papertex@insideweather}{false}
}
%    \end{macrocode}
%
%
% Author block.
%
%    \begin{macrocode}
\newenvironment{authorblock}[0]
{
	\ifthenelse{\boolean{papertex@insidefrontpage}}{%
		\begin{textblock}{15}(36,35)
			\setlength{\fboxsep}{5pt}
			\begin{papertex@fmpage}{13\TPHorizModule}
			\begin{minipage}{13\TPHorizModule}
				\centering
				\minilogo
		
	}{%else
		\ClassError{paperTeX}{%
			authorblock in a wrong place.\MessageBreak
			authorblock may only appear inside frontpage environment.
		}{%
			authorblock may only appear inside frontpage environment.
		}
	}
}
{
		\end{minipage}
		\end{papertex@fmpage}
	\end{textblock}
}
%    \end{macrocode}
%
%
% Main index block.
%
%    \begin{macrocode}
\newenvironment{indexblock}[1]
{
	\ifthenelse{\boolean{papertex@insidefrontpage}}{%
		\setboolean{papertex@insideindex}{true}%let's in
		\begin{textblock}{15}(36,16)
			\setlength{\papertex@indexwidth}{13\TPHorizModule}
			\papertex@indexFrameTitle{#1}
			
			\setlength{\fboxsep}{5pt}	%espacio entre el frame y la imagen
			\begin{papertex@fmpage}{\papertex@indexwidth}
				\begin{minipage}{\papertex@indexwidth}
					\vspace*{10pt}
	}{%else
		\ClassError{paperTeX}{%
			indexblock in a wrong place.\MessageBreak
			indexblock may only appear inside frontpage environment.
		}{%
			indexblock may only appear inside frontpage environment.
		}
	}
}%
{
				\end{minipage}
			\end{papertex@fmpage}
		\end{textblock}
		\setboolean{papertex@insideindex}{false}%let's out
}
%    \end{macrocode}
%
%
% Index item.
%
%    \begin{macrocode}
\newcommand{\indexitem}[2]
{
	\ifthenelse{\boolean{papertex@insideindex}}{
		\papertex@indexEntry{#1~\papertex@indexEntryPage{\pageref{#2}}}
		
		\vspace{0.5cm}
		
		\noindent\ignorespaces\indexEntrySeparator{}
	}{%else
		\ClassError{paperTeX}{%
			\protect\indexitem\space in a wrong place.\MessageBreak
			\protect\indexitem\space may only appear inside indexblock environment.
		}{%
			\protect\indexitem\space may only appear inside indexblock environment.\MessageBreak
			indexblock environment may only appear inside frontpage environment.
		}%
	}
}
%    \end{macrocode}
%
%
% \subsection{Inner news}
%
% Next two macros create an expanded title. The first command one is called inside the second one.
% They create a framed title that expands over all news columns. It can be used inside a |news| environment.
% It uses \texttt{fancybox} frame types and a custom one: text between two horizontal lines.
%    \begin{macrocode}
\newcommand{\papertex@inexpandedtitle}[1]{
	\begin{minipage}{.95\textwidth}
	\begin{center}
	\noindent\Large\textbf{#1}
	\end{center}
	\end{minipage}
}

\newcommand{\expandedtitle}[2]{
	\end{multicols}
		
	\begin{center}
	\setlength{\fboxsep}{5pt}
	\setlength{\shadowsize}{2pt}
	\ifthenelse{\equal{#1}{shadowbox}}{%
		\shadowbox{%
			\papertex@inexpandedtitle{#2}%
		}%
	}{}
	\ifthenelse{\equal{#1}{doublebox}}{%
		\doublebox{%
			\papertex@inexpandedtitle{#2}%
		}%
	}{}
	\ifthenelse{\equal{#1}{ovalbox}}{%
		\ovalbox{%
			\papertex@inexpandedtitle{#2}%
		}%
	}{}
	\ifthenelse{\equal{#1}{Ovalbox}}{%
		\Ovalbox{%
			\papertex@inexpandedtitle{#2}%
		}%
	}{}
	\ifthenelse{\equal{#1}{lines}}{
		\hrule
		\vspace*{8pt}
		\begin{center}
		\noindent\Large\textbf{#2}
		\end{center}
		\vspace*{8pt}
		\hrule
	}{}
	\end{center}

	\begin{multicols}{\papertex@ncolumns{}}
	\ifnum \papertex@ncolumns > \minraggedcols
	\raggedFormat
	\fi
}
%    \end{macrocode}
%
% The same as before but the title does not expand over news columns.
%    \begin{macrocode}
\newcommand{\papertex@incolumntitle}[2]{
	\begin{minipage}{#1}
	\begin{center}
	\noindent\normalsize\textbf{#2}
	\end{center}
	\end{minipage}
}

\newcommand{\columntitle}[2]{
	\vspace*{5pt}
	\begin{center}
	\setlength{\fboxsep}{5pt}
	\setlength{\shadowsize}{2pt}
	\addtolength{\papertex@coltitsize}{\columnwidth}
	\addtolength{\papertex@coltitsize}{-1\columnsep}
	\addtolength{\papertex@coltitsize}{-5pt}
	\addtolength{\papertex@coltitsize}{-1\shadowsize}
	\ifthenelse{\equal{#1}{shadowbox}}{%
		\shadowbox{%
			\papertex@incolumntitle{\papertex@coltitsize}{#2}%
		}%
	}{}
	\ifthenelse{\equal{#1}{doublebox}}{%
		\doublebox{%
			\papertex@incolumntitle{\papertex@coltitsize}{#2}%
		}%
	}{}
	\ifthenelse{\equal{#1}{ovalbox}}{%
		\ovalbox{%
			\papertex@incolumntitle{\papertex@coltitsize}{#2}%
		}%
	}{}
	\ifthenelse{\equal{#1}{Ovalbox}}{%
		\Ovalbox{%
			\papertex@incolumntitle{\papertex@coltitsize}{#2}%
		}%
	}{}
	\ifthenelse{\equal{#1}{lines}}{
		\hrule
		\vspace*{5pt}
		\begin{center}
		\noindent\normalsize\textbf{#2}
		\end{center}
		\vspace*{5pt}
		\hrule
	}{}
	\end{center}
}
%    \end{macrocode}
%
%
% Formating the heading date. This macro uses \texttt{datetime} package. I did some modifications on ``datetime.sty'' 
% file in order to satisfy my own need but I do not think people should change anything.
%    \begin{macrocode}
\renewcommand{\date}{%
	\longdate{\today}%
}
%    \end{macrocode}
%
% The next macro types out the author and the place of the news. It is just a format command.
%    \begin{macrocode}
\newcommand{\authorandplace}[2]{%
	\leftline{%
		{\innerAuthorFormat #1},\space{}{\innerPlaceFormat #2}%
	}%
	\par %
}
%    \end{macrocode}
%
% New section macro creates a new PDF bookmark and keeps track of which section we are. This is useful 
% because we would like to print out the section name on all page headings.
%    \begin{macrocode}
\newcommand{\newsection}[1]{
	\pdfbookmark[0]{#1}{\thepage} %bookmark para el pdf
	\renewcommand{\papertex@section}{#1}
}
%    \end{macrocode}
%
%
% Inner news environment. This enviroment creates a piece of news inside the newspaper. 
% It creates a \texttt{multicol} environment in the opening and ends it at closing. 
% It also uses \texttt{multicol} feature to expand the news headings all over the columns and creates a 
% new PDF bookmark and label.
%
% The fifth parameter gets the name of the label that the user can use in the front page index. It uses |\phantomsection| to make |\pageref| work. Notice that \papertex{} has not any sections.
%
% It tells |multicols| environment that it should appear $4cm$ of text at least. 
% Otherwise, it changes to a new page.
%    \begin{macrocode}
\newenvironment{news}[5]
{
	\papertex@say{Adding a new piece of news}
	\renewcommand{\papertex@ncolumns}{#1}
	\begin{multicols}{#1}[%
		\papertex@pages{#4}
		\papertex@innerTitle{#2}%
		\papertex@innerSubtitle{#3}%
		][4cm]%
	\phantomsection
	\pdfbookmark[1]{#2}{\thepage}
	\label{#5}
	\ifnum #1 > \minraggedcols
	\raggedFormat
	\fi
}
{~\innerTextFinalMark{}
\end{multicols}
}
%    \end{macrocode}
%
%
% Thin line to put between news. The line will not show up if there is not enough space. 
% For example, it will never appear at the top of a new page.
%    \begin{macrocode}
\newcommand{\newssep}{%
	\setlength{\papertex@pageneed}{16000pt}
	\setlength\papertex@pageleft{\pagegoal}
	\addtolength\papertex@pageleft{-\pagetotal} 
	
	\papertex@say{How much left \the\papertex@pageleft}
	
	\ifdim \papertex@pageneed < \papertex@pageleft
		\papertex@say{Not enough space}
	\else
		\papertex@say{Adding sep line between news}
		\vspace*{10pt plus 10pt minus 5pt}
		\hrule
		\vspace*{10pt plus 5pt minus 5pt}
	\fi

}
%    \end{macrocode}
%
%
% Next command inserts the opinion news heading. It is very different from normal news.
% I writes the title, a thin line and the author (usually in small caps). It uses a tabular in order 
% the line as wide as the titles.
%    \begin{macrocode}
\newcommand{\papertex@editorialTit}[2]{
	\setlength{\arrayrulewidth}{.1pt}
	\begin{center}
	\begin{tabular}{c}
	\noindent
	\papertex@editorialTitle{#1}
	\vspace{2pt plus 1pt minus 1pt}
	\\
	\hline
	\vspace{2pt plus 1pt minus 1pt}
	\\
	\editorialAuthorFormat{#2}
	\end{tabular}
	\end{center}
}
%    \end{macrocode}
%
%
% Next environment introduces a new opinion news. It tells |multicols| environment that 
% it should appear $4cm$ of text at least. Otherwise, it changes to a new page.
%    \begin{macrocode}
\newenvironment{editorial}[4]
{
\papertex@say{Adding a new editorial}
\begin{multicols}{#1}[%
	\papertex@editorialTit{#2}{#3}%
][4cm]
\phantomsection
\pdfbookmark[1]{#2}{\thepage}
\label{#4}
\ifnum #1 > \minraggedcols
\raggedFormat
\fi
}
{
\end{multicols}
}
%    \end{macrocode}
%
%
% Next command inserts the short news heading. It is very different from normal news.
%    \begin{macrocode}
\newcommand{\papertex@shortnewsTit}[2]{
	\begin{center}
	\vbox{%
	\noindent
		\papertex@shortnewsTitle{#1}
		\vspace{4pt plus 2pt minus 2pt}
		\hrule
		\vspace{4pt plus 2pt minus 2pt}
		\papertex@shortnewsSubtitle{#2}
	}
	\end{center}
}
%    \end{macrocode}
%
%
%Next environment introduces a short news group.
%    \begin{macrocode}
\newenvironment{shortnews}[4]
	{
	\papertex@say{Adding a short news block}
	\begin{multicols}{#1}[\papertex@shortnewsTit{#2}{#3}][4cm] %
	\phantomsection
	\pdfbookmark[1]{#2}{\thepage}
    \label{#4}
	\par %
	\ifnum #1 > \minraggedcols
	\raggedFormat
	\fi
	}
	{
	\end{multicols}
	}
%    \end{macrocode}
%
%
% This command is used to add short news items inside a short news group.
%    \begin{macrocode}
\newcommand{\shortnewsitem}[2]{
	\goodbreak
	\vspace{5pt plus 3pt minus 3pt}
	{\vbox{\noindent\papertex@shortnewsItemTitle{#1}}}
	\vspace{5pt plus 3pt minus 3pt}
	{\noindent #2}\\
}
%    \end{macrocode}
%
%
%
% \PrintIndex
% \PrintChanges
% \Finale
\endinput