Generalmerging LATEX files into one LATEX file (not a PDF or othe

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
akaplan1
Posts: 4
Joined: Fri Oct 24, 2014 4:43 am

merging LATEX files into one LATEX file (not a PDF or othe

Post by akaplan1 »

Hi folks; I am new to the forum, and in general more of a dumb user than an expert.
I am submitting a new paper to the arXiv, and I have TWO LATEX files, while they require only ONE LATEX file. So I need to merge my files into one -- but it's got to be a LATEX file. So regular commands like "\include" or "\input" don't work for me for they would generate as an output only PDF of GS merged files. I failed to find an appropriate recipe; can anybody help me? I work with ubuntu LINUX, 13.1 I believe...
Thanks,
Alex

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

StarValkyrie
Posts: 89
Joined: Fri Jan 24, 2014 12:42 am

Re: merging LATEX files into one LATEX file (not a PDF or

Post by StarValkyrie »

Okay, let's just rule out the obvious first - presumably you can't just cut and paste, perhaps because the two are different document classes?
akaplan1
Posts: 4
Joined: Fri Oct 24, 2014 4:43 am

merging LATEX files into one LATEX file (not a PDF or othe

Post by akaplan1 »

StarValkyrie wrote:Okay, let's just rule out the obvious first - presumably you can't just cut and paste, perhaps because the two are different document classes?
Correct, they are of different classes; sorry for not mentioning it before.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

merging LATEX files into one LATEX file (not a PDF or othe

Post by Johannes_B »

Hi and welcome,
two documentclass? Now my question: Why? We might lead you to alternatives, but we have to know what is going on.

From the top of my head, i would suggest compiling one file and inputting the resulting pdf in the document. Not sure, if this would be ok with arXiv tough.

Another thing is always the filecontents-environment writing it's contents to a file at run time.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
akaplan1
Posts: 4
Joined: Fri Oct 24, 2014 4:43 am

merging LATEX files into one LATEX file (not a PDF or othe

Post by akaplan1 »

Johannes_B wrote:Hi and welcome,
two documentclass? Now my question: Why? We might lead you to alternatives, but we have to know what is going on.

From the top of my head, i would suggest compiling one file and inputting the resulting pdf in the document. Not sure, if this would be ok with arXiv tough.

Another thing is always the filecontents-environment writing it's contents to a file at run time.
Johannes, thanks.
> compiling one file and inputting the resulting pd
Well, of course I can simply produce two PDF files and then just merge them, by using any PDF-merging command, e. g. pdfunite. I've done that, and submitted to arXive. They wrathfully rejected it -- no PDF generated from LATEX is for them... I expect the same problem with Phys. Rev. Lett.

> the filecontents-environment writing
Well, I am afraid you are talking over my head. It might be helpful if you were a bit more specific... Frankly, the entire LATEX thing is a bit foreign to me; I came from "troff" and UNIX -- you have a dinosaur here...

Once again -- I need a merged file to be again a full blown LATEX, whatever the procedure might be called.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

merging LATEX files into one LATEX file (not a PDF or othe

Post by Johannes_B »

Please copy the following and run it using pdflatex
-shell-escape
. It includes another document using
filecontents, compiles this document and later includes it using
package pdfpages.

Code: Select all

\begin{filecontents}{\jobname-external.tex}
	\documentclass{article}
	\usepackage{showframe}
	\begin{document}
	\Huge I am the external document
	\clearpage
	I am on the next page.
	\end{document}
\end{filecontents}
\documentclass{scrartcl}
\usepackage{pdfpages}
%The following line is just for demonstration and should in
%general not be done
\immediate\write18{pdflatex \jobname-external}
\begin{document}
I am an article using documentclass \texttt{scrartcl} and i can
include pdf files using package \texttt{pdfpages}.
\includepdf[pages=-]{\jobname-external.pdf}
This again is the \emph{mother} document. Did you notice the
different page sizes?
\end{document}
Please note that filecontents is a very basic command. As a UNIX
user, you should be familiar with reading documentation and
finding stuff ;-) LaTeX is about 30 years old, the recent kernel is
in place for 20 years. One might say this is a bit of history on
it's own.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
akaplan1
Posts: 4
Joined: Fri Oct 24, 2014 4:43 am

Re: merging LATEX files into one LATEX file (not a PDF or

Post by akaplan1 »

Johannes, great thanks!
Will start working on it right away. The way I understand it at the moment, is that I
do the first file as a "regular" LATEX file, and as a next step include another one
-- this time a PDF-file. If this is true, I suspect I'll get kicked out by arXiv (they
hate PDF in any form or shape), but at least I'll learn a new trick :)
Thanks again.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

merging LATEX files into one LATEX file (not a PDF or othe

Post by Johannes_B »

Johannes_B wrote:two documentclass? Now my question: Why? We might lead you to alternatives, but we have to know what is going on.

Hi, you still haven't given us a simple clue on what the different files are. There might be a super simple solution to this.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

merging LATEX files into one LATEX file (not a PDF or othe

Post by Johannes_B »

The explanation: the filecontents environment writes its content to a file specified in the argument, in this case \jobname-external.tex (basenameOfYourMainFile-external.tex). You can write any text you want to a file, scientific data, bibliogrphies ...

This file is later compiled by pdflatex through the line immediate\write18{pdflatex \jobname-external}.

The generated pdf is included in the document using package pdfpages. You can include any pdf document.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply