latex
latex copied to clipboard
\BLOCK do not work inside the \input{another_latex_file.tex}
i have multiple latex file so thats a reason. report_base.tex hold multiple latex file. for example. report_base.tex contains :
\begin{document}
\input{\VAR{report_dir}titlepage.tex}
\end{document}
==================================================== titlepage.tex contains :
\section{Project Overview}
\label{sec:proj-overview}
\begin{xltabular}[l]{\linewidth}{cXcX}
\rowcolor{\colorthG} ID & Vulnerability & Severity Level & Recommendations \\
\BLOCK{ for task, list_of_vulnerabilities in vulnerabilities.items() }
\rowcolor{\colorvul}\multicolumn{4}{c}{\textcolor{white}{\VAR{task}}}\\
\BLOCK{ endfor }
\end{xltabular}
But it gives error.

TL;DR: What you are doing is not supported
Note: I make a distinction between LaTeX file and LaTeX template.
- LaTeX template is (my name for) LaTeX interleaved with Jinja2 syntax (like
\BLOCK
and\VAR
), it should be processed by Jinja2 before it becomes a so called "LaTeX file". - LaTeX file is (my name for) plain LaTeX that can immediately be parsed by the TeX engine.
What you are doing is including a LaTeX template from a LaTeX file (because I assume you have rendered report_base.tex
with Jinja). The TeX engine has no clue what to do with \BLOCK
and \VAR
, as it is not valid LaTeX code.
An easy but ugly solution would be to render the LaTeX templates to plain TeX and store them in a folder. After that, compile your report_base.tex
.
A nicer solution would be rather complex but would probably require to search for \input
\include
macros in the LaTeX template. Then recursively render all includes and somehow (by saving to disk and changing path??) inject the rendered LaTeX.
There are more solutions obviously, but these are I think the two most attainable ones.