Problem \include-ing multiple .tex files

I am \include-ing multiple .tex files and I am using a package I found on the web for a one-column abstract in a two-column document (long2.sty):

%%
%% This is file long2.sty'.
%%
%% Author: Tomas "tohecz" Hejda <tohecz@gmail.com>
%%
%% Licenced under LaTeX-Project Public License version 1.3 or newer.
%%
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{long2}[2012/08/19 v0.1 long2: breakable one-column preamble in a two-column document]

\newlength\longtwo@top
\newlength\longtwo@bottom

\newsavebox\longtwo@box
\def\longtwo@repeat{%
\longtwo@column[{\@twocolumnfalse
\ifdim\ht\longtwo@box>1.00\textheight%1
\begingroup
\vbadness10000
\setbox0\vsplit\longtwo@box to 1.00\textheight%1
\setbox1\vbox{\unvbox\longtwo@box}
\global\setbox\longtwo@box\vbox{\unvbox1}
\setbox2\vbox to \textheight{%
\unvbox0
}
\ht2=0.9\textheight
\box2
\endgroup
\else
\ifdim\ht\longtwo@box>0.84\textheight
\global\let\longtwo@repeat\clearpage
\else
\global\let\longtwo@repeat\relax
\fi
\unvbox\longtwo@box
\vspace{15pt plus 15pt}
\fi
}]%
\longtwo@repeat
}

\long\def\longtwo@[#1]{%
\begingroup
\let\longtwo@column\twocolumn
\let\longtwo@mkttl\maketitle
\def\maketitle{
\begingroup
\let\newpage\relax
\longtwo@mkttl
\endgroup
}
\longtwo@column[{\@twocolumnfalse
\global\setbox\longtwo@box\vbox{#1}%
\ifdim\ht\longtwo@box>\textheight
\begingroup
\vbadness10000
\setbox0\vsplit\longtwo@box to 1.00\textheight%1
\setbox1\vbox{\unvbox\longtwo@box}%
\global\setbox\longtwo@box\vbox{\unvbox1}%
\setbox2\vbox to \textheight{%
\unvbox0
}
\ht2=0.9\textheight
\box2
\endgroup
\else
\ifdim\ht\longtwo@box>0.87\textheight
\global\let\longtwo@repeat\clearpage
\else
\global\let\longtwo@repeat\relax
\fi
\unvbox\longtwo@box
\fi
}]%
\longtwo@repeat
\endgroup
}

\def\longtwocolumn{\@ifnextchar[\longtwo@\twocolumn}

\endinput
%%
%% End of file long2.sty'.
%%


The first \include works great, but the abstract of the others gets overlapped the text. Any idea? Is there a way to tell LaTeX to reset everything and start a new document inside another each time I \include a file?

long2.sty is capable of splitting too long abstracts in two pages. That's why I use it.

My code is not very complex, the part with the \include is:

[...]
\pagestyle{fancy}
\clearpage
\resetearcontadores
\include{file1}
\resetearcontadores
\include{file2}
\resetearcontadores
\include{file3}
\resetearcontadores
\include{file4}
\clearpage
\pagestyle{empty}
[...]


The \resetearcontadores command just resets figure, table, etc counters. If you need more code (preamble, body or something) ask me, I just don't know what to show you because the code is very simple.

I know the \twocolumn command accepts an optional argument, but it doesn't split into pages and you can't use any environments.

-
Here is a link to a pdf with the problem: dropbox.com/s/mbcnm80txae9yqk/Example.pdf – Agustin May 14 '13 at 2:35
Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – Xavier May 14 '13 at 3:26
And a tip: You can use backticks  to mark your inline code as I did in my edit. – Xavier May 14 '13 at 3:28
Could you edit your question and add a minimal working example (MWE) that illustrates your problem (not just the long2 package you rely on)? It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Xavier May 14 '13 at 3:33
The basic problem is to make latex wrap the abstract into two pages. My abstract is too long (actualy there are two abstract) so \abstract doesn't works for me because it doesn't slip it into the next page. Thats why I use the long2 package but now I think that using it is the problem. I tried with \subfile too. – Agustin May 15 '13 at 20:56

1 Answer

Initial typesetting of section 2.

It would really have helped if you had provided a complete document, as below, to save anyone trying to help having to make one and then try to guess the problem that you are seeing. However...

The problem is unrelated to \include you see the same with \input or in fact with the content all being in one file, however the example below uses include.

The long2 code is clearly aimed at making titlepages and like most LaTeX title handling it is not designed to be used multiple times, as it redefines itself during use.

However if you save an initial definition after loading the package and reset it before each use, it appears to work OK.

Document after adding code to resetting \longtwo@repeat.

\begin{filecontents}{\jobname a.tex}
\begin{longabstract}
AAAAAA AAAAAA AAAAAA
\c

\b\b\c
\end{longabstract}
\section{Something}
\a\a\a\c\b
\end{filecontents}
\begin{filecontents}{\jobname b.tex}
\begin{longabstract}
BBB BBB BBB
\c

\a\a\a\c\b
\end{longabstract}
\section{Something Else}
SSS SSS SSS SSS SSS
\b\c\b\a\a\a
\end{filecontents}

\documentclass[twocolumn,a5paper]{article}
\pdfpagewidth\paperwidth
\pdfpageheight\paperheight
\usepackage{long2,environ}
\def\a{\stepcounter{enumi}One two three four five \roman{enumi}. }
\def\b{Red yellow blue green purple orange. \a\a\a\a}
\def\c{\b\b\a Monday tuesday wednesday thursday friday saturday sunday.
\b\b\b\a England France Germany Spain Poland Canada. \b\b}

\makeatletter
\let\xlongtwo@repeat\longtwo@repeat

\NewEnviron{longabstract}
{\let\longtwo@repeat\xlongtwo@repeat
\longtwocolumn[\begin{abstract}\BODY\end{abstract}]}{}

\makeatother

\begin{document}
\include{\jobname a}
\include{\jobname b}
\end{document}
`
-