Banner

Donate

You find LaTeX Community useful? Please donate! Learn why!

Amount:

Partner Sites

goLaTeX
TeXblog
TeXnicCenter

Who is online

In total there are 20 users online :: 2 registered, 0 hidden and 18 guests (based on users active over the past 5 minutes)
Most users ever online was 108 on Tue Jun 08, 2010 3:33 pm

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 18 guests

Combining or merging several TEX files into one document?

LaTeX specific issues not fitting into one of the other forums of this category.

Combining or merging several TEX files into one document?

Postby Jay on Tue May 06, 2008 8:07 pm

To start: I'm using TexLive2007 on OS X 10.5.2 and TeXShop as my environment. I'm a noob at this first month using LaTex andmy first try at a large document. I've google searched the heck out of this problem and looked in all the FAQs and textbooks. I can't find anything. An earlier post on this forum suggest the same approach should work that I've used.

I'm using a file called "Main.tex". Within this file is the code below. I have approx. 15 tex files (named here as file1 ... file4). I'd like to only have Main.tex call up these Tex files and typeset them into one PDF. All the Tex files 1 through 15 work correctly and the document looks fine. No errors.

You'll see that I've commented out several lines, which comprise of "\include{} statements. I've tried to combine the files using both \input and \include (substituting out the commented lines) and doing this in the preamble and after the \begin{document}. None of it works. The only think I've accomplished so far is to get file one to "typeset" into PDF - even when \input{file2} is included. I've also removed the \begin and \end statments and it seems to work even without the \usepackage{combine} but it only typesets

Code: Select all
%\usepackage{combine}
%\documentclass[final]
\input{file1}
\input{file2}
\begin{document}
%\pagestyle{combine}
%\include{file3}
%\include{file4}
%\begin{document}
\input{file1}
\input{file2}
%\include{file3}
%\include{file4}
\end{document}


I should add, from some of the references I've seen, to use the \input or \include commands, you need to call up the combine package. This doesn't seem to be included in TexLive so I downloaded it from CTAN and installed it in my ~....texmf/tex/latex directory.

Again, I'm a noob at this. Perhaps there's another way to combine the files? Sorry for length. I know sometimes posts aren't detailed enough and it doesn't help anybody. :) I would greatly appreciate any feedback.
Jay
 
Posts: 2
Joined: Tue May 06, 2008 7:48 pm

Re: Combining or merging several TEX files into one document?

Postby gmedina on Tue May 06, 2008 8:21 pm

Jay wrote:
Code: Select all
%\usepackage{combine}%this line should not be here
%\documentclass[final]%final is not a document class file
\input{file1}%this line should not be here
\input{file2}%this line should not be here
\begin{document}
%\pagestyle{combine}%??
%\include{file3}
%\include{file4}
%\begin{document}%more than one \begin{document}!!
\input{file1}
\input{file2}
%\include{file3}
%\include{file4}
\end{document}


If I correctly understood your question then you do not need the combine package.

Try this simple example:
Main.tex:
Code: Select all
\documentclass{book}
\usepackage{lipsum}% automated generation of text

\begin{document}
\include{file1}
\include{file2}
\end{document}

file1.tex:
Code: Select all
\chapter{First chapter}
\lipsum[1-20]

file2.tex:
Code: Select all
\chapter{Second chapter}
\lipsum[1-20]
As you can see, the preamble goes in Main.tex and not in the subsidiary files.

Process Main.tex only.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
gmedina
 
Posts: 2056
Joined: Wed Jul 11, 2007 10:45 pm
Location: Colombia

Re: Combining or merging several TEX files into one document?

Postby Jay on Tue May 06, 2008 11:27 pm

I've gotten it to work! The problem, and it wasn't specified in the sites/documentation I read was that only the Main.tex (in this example) should have the \begin{document} .... \end{document} tags as well as all the preamble.

Your suggestion of:
As you can see, the preamble goes in Main.tex and not in the subsidiary files.
was a real save. Thank you, Thank you, Thank you! :) I spent 8 hours working on this.

Now my documents are being Typeset correctly. There's some errors, mostly it looks like 'hbox badness' and bibcite problems. I have a lot of references in these documents using the APA and MLA formats. I'm just using \bibitem{1} .... Bibliography information for document ...... and on for the rest of the citations. I think its because if its a longpiece:(of)text,likethis which is sometimes how the bibs have to be written (without spaces), it will foobar the bibitem. If I just hit return it continues to Typeset correctly. I'll continue onwards unless someone has a quick-easy suggestion to fix.

Thanks again gmedina.
Jay
 
Posts: 2
Joined: Tue May 06, 2008 7:48 pm

Re: Combining or merging several TEX files into one document?

Postby tripwire45 on Tue Jun 03, 2008 6:34 pm

Sorry to bring this thread "back from the dead", but it's a subject that's just been presented to me here at my work.

I maintain a user manual for a specific product that includes several step-by-step exercises. The output is in PDF format which works fine, since the user manual is distributed in both PDF and hardcopy.

The primary interface for our product is web-based and the developers want to be able to take just the exercises I've created (and not the other content in the user manual) and use them to create HTML help pages. They propose that I create each step-by-step exercise as a series of separate .tex files that they can then "pull" from subversion (where all our content is committed) generate as HTML, and insert in the product's web interface as help pages.

I can certainly create the exercises as separate files and then use the \include tag to insert the exercises at the required points in the user manual. However, will the developers be able to use the individual exercises files as I've described, or is there a better way to accomplish this task?

Thanks.

-Trip
User avatar
tripwire45
 
Posts: 125
Joined: Thu Apr 10, 2008 3:35 am

Re: Combining or merging several TEX files into one document?

Postby tripwire45 on Mon Jun 09, 2008 4:27 pm

:bump:

Any ideas?

Thanks.
User avatar
tripwire45
 
Posts: 125
Joined: Thu Apr 10, 2008 3:35 am

Re: Combining or merging several TEX files into one document?

Postby T3. on Mon Jun 09, 2008 11:07 pm

Hi Trip,

Look at tex4ht and latex2html for html generation from latex sources. As a bare bones solution you could do the following:
Code: Select all
echo \input{preamble.tex}\begin{document}\input{exercise.tex}\end{document}>test.tex
htlatex test.tex

Of course you will need some extra code to 'pull' .tex files from subversion as needed but I hope you get the idea. Simply generate automatically latex files with required fragments of your manual and convert them to html.

Cheers,

Tomek
User avatar
T3.
 
Posts: 199
Joined: Fri Mar 14, 2008 11:58 am

Re: Combining or merging several TEX files into one document?

Postby tripwire45 on Tue Jun 10, 2008 2:52 pm

Thanks, Tomek. The "powers-that-be" are still discussing how they want to do this and I can certainly present this as one solution. I've already looked at tex4ht and latex2html as you've suggested. Cheers. :)

-Trip
User avatar
tripwire45
 
Posts: 125
Joined: Thu Apr 10, 2008 3:35 am

Re: Combining or merging several TEX files into one document?

Postby pankajgpatel on Fri Feb 12, 2010 5:10 am

Hello Friends:
I am new to using Latex. I need to make a book out of the 20 chapters (with tex files that are working fine individually).I have been given working compiled 20 chapters with tex files written in Latex that I need to combine in one file. I tried the way described earlier.I made a master.tex where I have preamble, begin, include{chapter1}, include{chapter2}......etc. and end statement. Each chapter compiles fine in Latex and produces perfect output when I compile individually (each chapter is having its own preamble, begin and end statements). But when I compile master.tex, it gives me lots of errors. What is the best way to invoke all these chapters without removing anything from individual chapters. I shall really appreciate your help.

Thanks a lot,
PAT
pankajgpatel
 
Posts: 1
Joined: Fri Feb 12, 2010 4:33 am

Re: Combining or merging several TEX files into one document?

Postby localghost on Fri Feb 12, 2010 9:09 pm

Try the combine class.


Best regards and welcome to the board
Thorsten
¹ I'm sorry. My responses are limited. You must ask the right questions.
² Systems: openSUSE 11.3, TeX Live 2009, TeXworks 0.3 | Windows XP (SP3), MiKTeX 2.8, TeXworks 0.3
³ Learning TeX.
User avatar
localghost
Site Moderator
 
Posts: 4769
Joined: Fri Feb 02, 2007 11:06 am
Location: Braunschweig, Germany


Return to General

Who is online

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 18 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group