
呼び出しを\DTLifnullorempty
別の呼び出し内に埋め込むと、 の呼び出しごとに余分なスペースが必要になる\DTLifnullorempty
ようです。この動作を防ぐ方法はありますか? 特に、次の MWE を使用して、各行と先行する資料の間に同じ量のスペースがあるドキュメントを生成したいと思います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}
答え1
スペースは追加した場所にのみ表示されます。
\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}