Es scheint, dass das Einbetten von Aufrufen \DTLifnullorempty
ineinander zu einem zusätzlichen Leerzeichen für jeden Aufruf von führt . Gibt es eine Möglichkeit, dieses Verhalten zu verhindern? Insbesondere möchte ich, dass das folgende MWE ein Dokument erstellt, in dem jede Zeile den gleichen Abstand zwischen und dem vorhergehenden Material \DTLifnullorempty
hat . Vergleichen Sie:AAA
\documentclass{article}
\setlength{\parindent}{0pt}
\begin{filecontents*}{test.csv}
One,Two,Three,Four
a,b,c,d
a,b,c,
a,b,,
a,,,
\end{filecontents*}
\usepackage{datatool}
\DTLloaddb{test}{test.csv}
\begin{document}
\section{Undesired output}
\frenchspacing
\DTLforeach*{test}{%
\One=One,
\Two=Two,
\Three=Three,
\Four=Four%
}{%
\One\DTLifnullorempty{\Four}{%
% If \Four is empty
% Check if \Three is empty
\DTLifnullorempty{\Three}{%
% If \Three is empty
% Check if \Two is empty
\DTLifnullorempty{\Two}{%
% If \Two is empty
.%
}{%
% If \Two is not empty
. \Two.
}
}{%
% If \Three is not empty
. \Two. \Three.%
}
}{%
% If \Four is not empty
. \Two. \Three. \Four.%
}
AAA\par
}
\section{Desired output}
a. b. c. d. AAA\par
a. b. c. AAA\par
a. b. AAA\par
a. AAA\par
\end{document}
Antwort1
Das Leerzeichen wird nur dort angezeigt, wo Sie es hinzugefügt haben:
\documentclass{article}
\setlength{\parindent}{0pt}
\begin{filecontents*}{test.csv}
One,Two,Three,Four
a,b,c,d
a,b,c,
a,b,,
a,,,
\end{filecontents*}
\usepackage{datatool}
\DTLloaddb{test}{test.csv}
\begin{document}
\section{Undesired output}
\frenchspacing
\DTLforeach*{test}{%
\One=One,
\Two=Two,
\Three=Three,
\Four=Four%
}{%
\One\DTLifnullorempty{\Four}{%
% If \Four is empty
% Check if \Three is empty
\DTLifnullorempty{\Three}{%
% If \Three is empty
% Check if \Two is empty
\DTLifnullorempty{\Two}{%
% If \Two is empty
.%
}{%
% If \Two is not empty
. \Two.%
}%
}{%
% If \Three is not empty
. \Two. \Three.%
}%
}{%
% If \Four is not empty
. \Two. \Three. \Four.%
}
AAA\par
}
\section{Desired output}
a. b. c. d. AAA\par
a. b. c. AAA\par
a. b. AAA\par
a. AAA\par
\end{document}