during my thesis I have multiple md (markdown) files in a git repository. All these md files are chapters of a final book pdf that I want to generate. I would like to use XeLatex so I am thinking of converting all md files to tex files (using pandoc) and then include them in final book.tex file that will export the pdf. (An alternative is to hard copy paste the content of 10 md files in a Latex book template but I think there is a more generic way). I wrote a Makefile in order to convert md files to tex like below:
pandoc file1.md -f markdown -t latex -s -o file1.tex
pandoc file2.md -f markdown -t latex -s -o file2.tex
….
pandoc file10.md -f markdown -t latex -s -o file10.tex
I run the Makefile and as a result I took 10 tex files. After that, I tried to include them in the final book.tex file
\documentclass{scrbook}
\begin{document}
\include{file1}
\include{file2}
…
\include{file10}
\end{document}
Each one tex file,as generated from pandoc, has it's own documentclass and i as a result i am getting error during compilation (Latex error: file1 can be used only in preamble). I tried to hard copy-paste the text of the first file in another tex file without documentclass and works fine, without errors. Is there a way to get the final tex file without copy-paste the content of each sub file? I believe that i need to add something in my Makefile in order to give only one tex file as a result.
Thanks for your attention. I’m looking forward to your reply.