\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}