1

i have 2 filecontent with different structure: test1.tex and test2.tex.

But i want to call data from only one file (ex:test.tex)

How can i build only one file test.tex that includes data of 2 file test1.tex and test2.tex?

My minimal code:

    \documentclass{article}
    \usepackage{datatool}
    \usepackage{filecontents}
    \usepackage{pgfplots}
    \usepackage{pgf}
    \usepackage{tikz}
\begin{filecontents*}{test1.tex}
Acol, Bcol, NoCol
Ax,Bx,1
Ay,By,3
A1,B22,2
A2,B44,4
A3,B11,5
\end{filecontents*}

\begin{filecontents*}{test2.tex}
\def\Names{{"ABC","XYZ"}}
\end{filecontents*}

\DTLloaddb{mydata}{test1.tex}
\input{test2.tex}
\pgfmathsetmacro{\NameNull}{\Names[0]}

\begin{document}

\DTLforeach*{mydata}{\A=Acol,\B=Bcol}%
{%

 \NameNull \hspace{2cm } \A \hspace{2cm } \B \\
 %\newpage
}%

\end{document}

i can manual copy all data from test1.tex and test2.tex to one file test.tex.

But please help how i arrange this data?

Ex:

\begin{filecontents*}{test.tex}

Data copy from test1.tex and can call to main.tex

Data copy from test2.tex and can call to main.tex

\end{filecontents*}

Thanks

Roland
  • 6,655
latexforti
  • 2,091
  • 1
    I'm afraid that what you want is difficult to understand. The example you gave already uses data from test1.tex (which is not a TeX file, rather CSV) and test2.tex. What else do you want? Do you want to read two files in CSV format from test.tex? If so, I think you have to process them one by one, with two calls to \DTLforeach*, each corresponding to a different database (e.g., \DTLloaddb{mydata1}{test1.tex} and \DTLloaddb{mydata2}{test2.tex}). – frougon Aug 26 '19 at 22:01
  • @frougon thank for your reply. I want to only one file: i can manual copy test1&test2 and past to one test.tex. How is structure of test.tex? Thanks – latexforti Aug 27 '19 at 10:54
  • 1
    Still not sure I understand what you mean. As people already told you, if you want to \input test1.tex and test2.tex from test.tex, then test1.tex and test2.tex can't have \documentclass, \begin{document}, \end{document}. When LaTeX processes one document, it must see one occurrence of these commands, no more. So, you can have a skeleton document in test.tex with two \input commands for test1.tex and test2.tex, but then these two files can't be full compilable documents: they can only be partial. For instance, they can contain macro definitions and you can use the macros in test.tex. – frougon Aug 27 '19 at 12:32
  • @frougon can you guide me that solution: using macros to definite test2 and test 1 in test.tex. And then in main.tex can call data from test.tex. Thank very much. – latexforti Aug 27 '19 at 15:28
  • 1
    I would like to, but I don't understand what you want to do, sorry. The description is too vague for me... – frougon Aug 27 '19 at 15:34
  • @frougon. thanks. i use one program Java and it can create automation text file. And i must create 2 file in Latex: test 1 (for columns: Acol, Bcol, NoCol...) and test 2 (for array: \def\Names{{"ABC","XYZ"}}) then i copy data 2 times from my program Java to two created files in Latex. I can reduce step if two test 2 and test 1 embeded in one test.tex file – latexforti Aug 27 '19 at 15:45

0 Answers0