LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-28-2007, 07:30 AM   #1
edgjerp
Member
 
Registered: Dec 2004
Location: Trondheim, Norway
Distribution: kubuntu 10.04
Posts: 308

Rep: Reputation: 31
LaTeX merge includes


is there a fast way to pull all \include{} files into the master document?

turn this:

master.tex:
{preamble}
\begin{document}
\include{a}
\include{b}
\include{c}
\end{document}

a.tex:
<contents of a>

b.tex:
<contents of b>

c.tex:
<contents of c>

------
into this:

master.tex
{preamble}
\begin{document}
<contents of a>
<contents of b>
<contents of c>
\end{document}

I know I can use copy/paste, but is there a latex function or method to do this in one go?
 
Old 02-28-2007, 08:26 AM   #2
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Rep: Reputation: 31
What editor are you using? Emacs has "include-file" bound to "C-x C-i". It's better than copy and paste. If you would really rather have the text there than use \include, you could do that, however that's just a variant of copy/paste.

Unless you're already dedicated to vi, I would strongly recommend Emacs/XEmacs with AUCTEX. Jed also has a LaTeX mode.

Joel
 
Old 02-28-2007, 10:49 AM   #3
edgjerp
Member
 
Registered: Dec 2004
Location: Trondheim, Norway
Distribution: kubuntu 10.04
Posts: 308

Original Poster
Rep: Reputation: 31
I mostly use kile, or any other editor (PCTeX, or even pico) when I am not by my own computer. I used include to make the file easier to manage when putting together, but I need to send the project to another person, and 1 file is simpler to deal with than 10+.
 
Old 02-28-2007, 02:21 PM   #4
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Do you like this one?
Code:
ada@barnabas:~/tmp> cat master.tex
\begin{document}
\include{a}
\include{b}
\include{c}
\end{document}
ada@barnabas:~/tmp> cat a.tex
<contents of a>
ada@barnabas:~/tmp> sed -e '/^\\include{a}/r a.tex' -e '/^\\include{a}/d' master.tex
\begin{document}
<contents of a>
\include{b}
\include{c}
\end{document}
 
Old 02-28-2007, 02:41 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
In vim you could also read a file where you wanted it included, using :r <filename>. Since you are only doing this once for the file you are sending, if I were you I would use emacs or vim for assembling the file you want to send. We aren't saying you should use vim or emacs to write your documents.

For kile, you could open the chapter files in another tab, use CTRL-A to select everything and then copy.

You could also cat the chapters together.
Ex: cat chapter1.tex chapter2.tex chapter3.tex ... >allchapters.tex

Then you could use cut and past only once to include them where you want.


A zip or tarball could be used as well to package the files. If this is a paper you are submitting they may have instructions on what they require.

I don't know of any pure latex solution to output a "post include" latex file. But you probably know latex much better than I do. A search on the CTAN site might turn up a pure latex or tex solution.

Last edited by jschiwal; 02-28-2007 at 03:06 PM.
 
Old 03-01-2007, 10:03 AM   #6
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Rep: Reputation: 31
Quote:
Originally Posted by jschiwal
[snip] We aren't saying you should use vim or emacs to write your documents.
[snip]
That's true, however I think you should at least check out the features of an editor with specific LaTeX modes (in the least). Does Kile have LaTeX modes? (that's a real question). AucTeX (under XEmacs) makes writing documents easier than any word processor ever did for me. Yes, Emacs/Xemacs are cumbersome and vi/m can be daunting, however you stand to gain a lot by considering it.

WHAT I WOULD DO: is concatenate the files like several others have suggested, if you really want all the text in the same file.

However, I use \include all the time, and since the documents I deal with often include figures and other auxiliary files, I would just tar up a directory and send it to somebody else. Remember, if you just tar the files, then they get spit out all over the destination directory. If you tar the directory, it makes a directory for the person untarring it.

Joel
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LaTeX forum / Where to ask LaTeX questions? max_sipos Linux - Software 2 12-21-2011 12:01 PM
About LaTeX and fonts in LaTeX g4j31a5 Linux - Software 4 09-19-2006 07:36 AM
convert and merge a fat32 to ext3 and then merge w/ another ext3? nkoplm Linux - General 3 03-23-2006 10:37 PM
merge two folders TechNett Programming 1 05-02-2005 08:38 AM
LaTeX commands: texi2pdf, latex, dvipdf kaon Linux - Software 7 01-23-2005 03:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration