-1

i use TexMaker 5.0.3

i have 6 file tex (file 1,2...6), and i must compile 6 times of 6 file .tex to create 6 file pdf. Then in main.tex, i combine 6 file pdf to only one pdf. Total: 7 times to create main.pdf My Minimal code in main.tex:

\documentclass[a5paper]{article}
\usepackage[a5paper,landscape,left=1.5cm,right=0.3cm,top=1cm,bottom=1cm]{geometry}

\usepackage{pdfpages}
\usepackage{subfiles}
\begin{document}
\includepdf[pages=-]{front_cover.pdf}
\includepdf[pages=-]{./Introduction/Introduction.pdf}
\includepdf[pages=-]{1.pdf}
\includepdf[pages=-]{2.pdf}
\includepdf[pages=-]{3.pdf}
\includepdf[pages=-]{4.pdf}
\includepdf[pages=-]{5.pdf}
\includepdf[pages=-]{6.pdf}
\end{document}

With "option: Define current Document = Master Document" : Don't work with command: \includepdf (i don't see any file in structrure view)

How can i compile only one time to create and combine main.pdf from 6 different file .tex (TexMaker)? Thank in advance

latexforti
  • 2,091

1 Answers1

2

If the 6 subfiles are .tex, then there is no need to include them as pdf in that way. All can be compiled in one go from your main.tex. This is easiest to explain with an example. Suppose I current have the files for a title page, an abstract and a section of text, with the following directory structure:

main.tex
files/
    titlepage.tex
    abstract.tex
    section1.tex

If main.tex has the contents:

\documentclass[a5paper]{article}
\usepackage{lipsum}
\usepackage[a5paper,landscape,left=1.5cm,right=0.3cm,top=1cm,bottom=1cm]{geometry}
\begin{document}
\input{files/titlepage}
\input{files/abstract}
\include{files/section1}
\end{document}

Then all three sub files appear in the final document when compiling main.tex. The relevant commands are input{file}, which inputs the text file into main.tex, and include{file}, which does the same but introducing a newpage:

output

Now, this assumes that each of the subfiles are plain 'content' without preambles or \begin{document}. For example, my `files/section1.tex' has

% !TeX root = ../main.tex
\section{First file}
\lipsum[1][1-5]

Note the first line here - this is a special command that tells the compiler that this document is being built from another file (specifically main.tex). Depending on your build system, this may not be necessary (but will do no harm either way).

If you would like to retain the ability to compile the subfiles separately, the standalone package if for you. This strips the preamble from the subfiles so you can \input them without any issues. To use this package, add \usepackage{standalone} to your preamble in main.tex and use \documentclass{standalone} in each subfile (for more information see the documentation).

Of course, you can combine this workflow with including pdfs in the usual way (e.g. if front_cover.pdf was not from a .tex file).

pip
  • 1,847
  • i tried. i used: \documentclass[a5paper]{article} \usepackage{lipsum} \usepackage[a5paper,landscape,left=1.5cm,right=0.3cm,top=1cm,bottom=1cm]{geometry} \begin{document} \input{files/titlepage} \input{files/abstract} \include{files/section1} \end{document} but many fails: https://imgur.com/SE1oHoF. Please look image – latexforti Feb 16 '19 at 05:57