0

I have multi file text: Main, Main01, main02, Main03...main10

How can I open only one window of main.tex and select one parameter to compile main01 or main02 or main03. and then receive created pdf of main01, or main02, or main03 in same window of Main.tex

Note: main01.tex, main02.tex...can compile alone (with begin/end{document} inside)

Example: In Main.tex:
%%%Please select one file to compile:
\select{main03.tex}
…

And main03.pdf is created. Thank you in advance

closed as unclear what you're asking by Mensch, siracusa, Phelype Oleinik, Raaja, Stefan Pinnow Jul 27 at 4:48

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Seems you want to use \include and \includeonly ... – Mensch Jul 15 at 11:34
  • 1
    If you really want only one of the files to be compiled and the others ignored (i.e., a select), I would use \input{main03}. – frougon Jul 15 at 11:35
  • 1
    @Mensch ... I think that the problem is that \include is for chapters and will create a "pagebreak". – koleygr Jul 15 at 11:55
  • 1
    @koleygr Well, that is sinply a wild guess and because there is a MWE in the question missing, we can't be sure. Let's see if the OP react and add more information to her/his question ... – Mensch Jul 15 at 11:58
1

Here is a way:

main.tex:

\documentclass{article}    
\usepackage{lipsum}
\usepackage{pgffor}

%Add the files you wish to be included here:
\def\onlyinput{main1,main2}

%Command definition
\newcommand{\minput}[1]{\def\xx{#1}\foreach \x in \onlyinput{\ifx\x\xx\input{#1}\fi}}

\begin{document}
\section{Standard Section}
\lipsum[1]
\minput{main1}
\minput{main2}
\end{document}

main1.tex:

\section{Main 1}
\lipsum[1]

main2.tex:

\section{Main 2}
\lipsum[1]

main3.tex:

\section{Main 3}
\lipsum[1]

Output:

enter image description here

  • it work if main1,main2 without begin/end document. Can you update for main01,main02 with begin/end{document} inside. And can simpler use with variable 1,2,3 instead file actual name? Thanks – latexforti Jul 15 at 12:26
  • Sorry but by not having a MWE this was my idea and it is not appropriate for full LaTeX files ... – koleygr Jul 15 at 12:35
0

You should use the ifthen package.

In your premable use:

\usepackage{ifthen}
\def\var{2}

And in the document:

\ifthenelse{\var=1}{
\input{file1.tex}
}{
\ifthenelse{\var=2}{
  \input{file2.tex}
}{}}

You can use \include or \input whether you want to start a new page or not respectively.

  • your code like that i want. i tried but error "File not found". \documentclass[twoside,8pt]{article} \usepackage[top=0.5cm, bottom=0.5cm]{geometry} \usepackage{ifthen} \def\var{2} \begin{document} \ifthenelse{\var=1}{ \input{mainl01.tex} }{ \ifthenelse{\var=2}{ \input{mainl02.tex.tex} }{}} \end{document} – latexforti Jul 15 at 11:54
  • 1
    you have an extra ".tex" in the mainl02 file. Are you sure your files are in the same folder as the main tex? – jorgepz Jul 15 at 11:59
  • when i use file1, file2 without begin/end{document}, it works. But my file main01,main02....have begin/end{document} inside and it don't works. Please look. Thanks – latexforti Jul 15 at 12:24
  • 2
    the files you include or input must not have the begin/end document. They should have only content. The input/include commands are equivalent to introducing the file content in that place, thus, writing \begin{document} twice in a same tex file produces an error. – jorgepz Jul 15 at 12:30
  • 1
    It is hard to give a solution without seeing the files to include, but I would suggest to put the commands before the begin document from all the files in the preamble of the main tex file and the do the input using ifthen as I said. Each input file must have only the content. – jorgepz Jul 15 at 14:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.