I am trying to test some macros inside csv data and I am obtaining very special results.
Test number 1 (look at the command \csvautobooktabular{macrodata.csv}):
\documentclass[a4paper,9pt]{book}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{csvsimple}
\usepackage{hyperref}
\usepackage{tikz}
\begin{document}
\begin{filecontents}{macrodata.csv}
type,description,content
M,A nice \textbf{formula}, $\displaystyle \int\frac{1}{x} = \ln|x|+c$
G,A \textcolor{red}{colored} ball, {\tikz \shadedraw [shading=ball] (0,0) circle (.5cm);}
M,\textbf{Another} formula, $\displaystyle \lim\limits_{n\to\infty} \frac{1}{n}=0$
\end{filecontents}
\begin{filecontents}{data.csv}
clé,nom,valeur
var1,numeric,32+1
var2,string,"text"
var3,float,3.14-x
var4,Latex,test
\end{filecontents}
\csvautobooktabular{macrodata.csv}
\section{Variables}\label{sec:var}
\begin{landscape}
\csvloop{
file=data.csv,
respect all,
separator=comma,
no head,
column names={1=\cola, 2=\colb, 3=\colc},
before reading={
\begin{table}
\centering
\begin{tabular}{llr}
\toprule
},
command={\csviffirstrow
{\textbf{\cola} & \textbf{\colb} & \textbf{\colc}}
{\addtocounter{csvrow}{-1}\hyperref[sec:a-\thecsvrow]{\cola}\addtocounter{csvrow}{1} & \colb & \colc}
},
late after line=\\,
late after first line=\\\midrule,
late after last line=\\\bottomrule,
after reading={
\end{tabular}
\caption{Liste des entités}
\label{tab:variables}
\end{table}
}
}
\end{landscape}
\subsection{Variable 1}\label{sec:a-1}
\dots
\subsection{Variable 2}\label{sec:a-2}
\dots
\subsection{Variable 3}\label{sec:a-3}
\dots
\subsection{Variable 4}\label{sec:a-4}
\dots\newline
\end{document}
This test seems to work correctly:
Now the second test:
\documentclass[a4paper,9pt]{book}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{csvsimple}
\usepackage{hyperref}
\usepackage{tikz}
\begin{document}
\begin{filecontents}{macrodata.csv}
type,description,content
M,A nice \textbf{formula}, $\displaystyle \int\frac{1}{x} = \ln|x|+c$
G,A \textcolor{red}{colored} ball, {\tikz \shadedraw [shading=ball] (0,0) circle (.5cm);}
M,\textbf{Another} formula, $\displaystyle \lim\limits_{n\to\infty} \frac{1}{n}=0$
\end{filecontents}
\begin{filecontents}{data.csv}
clé,nom,valeur
var1,numeric,32+1
var2,string,"text"
var3,float,3.14-x
var4,Latex,test
\end{filecontents}
\section{Variables}\label{sec:var}
\begin{landscape}
\csvloop{
file=data.csv,
respect all,
separator=comma,
no head,
column names={1=\cola, 2=\colb, 3=\colc},
before reading={
\begin{table}
\centering
\begin{tabular}{llr}
\toprule
},
command={\csviffirstrow
{\textbf{\cola} & \textbf{\colb} & \textbf{\colc}}
{\addtocounter{csvrow}{-1}\hyperref[sec:a-\thecsvrow]{\cola}\addtocounter{csvrow}{1} & \colb & \colc}
},
late after line=\\,
late after first line=\\\midrule,
late after last line=\\\bottomrule,
after reading={
\end{tabular}
\caption{Liste des entités}
\label{tab:variables}
\end{table}
}
}
\end{landscape}
\subsection{Variable 1}\label{sec:a-1}
\dots
\subsection{Variable 2}\label{sec:a-2}
\dots
\subsection{Variable 3}\label{sec:a-3}
\dots
\subsection{Variable 4}\label{sec:a-4}
\dots\newline
\csvautobooktabular{macrodata.csv}
\end{document}
Consequently, I just moved the csvautobooktabular command to the end of the document and surprisingly, in the second case, it gave me a table that looks like this:
Clearly, in the second test macros inside the data file are not functional anymore. Why is this and where is my mistake?




csvautobooktabular(combining the two test), the first work the second not anymore ... – Certes Oct 05 '22 at 12:10