This code leaves an empty row at the bottom:
\documentclass{article}
\usepackage{etoolbox}
\def\somedef{foo}
\begin{document}
\begin{tabular}{|l|}
\hline
First row, not important \\ \hline
\ifdefstring{\somedef}{bar}{never used \\ \hline}{}%
\end{tabular}
\end{document}
The resulting table looks like:
----------------------------
| First row, not important |
+--------------------------+
| |
It's that bogus empty row at the bottom that I want to get rid of.
I know I can make this work by replacing the \ifdefstring
with something like:
\ifnum\pdfstrcmp{\somedef}{bar}=0 never used \\ \hline \else\fi
But I'm interested in sticking to etoolbox, which seems to be a fairly comprehensive package with many relatively easy to read macros (for programmers, my audience). I'm also interested in using the conditional inline within the table, as that seems easiest to read and maintain. (If there's a better package that is similarly comprehensive that I should be using instead and it doesn't have the above problem, I'm very interested in hearing about that, too.)
How can I use etoolbox's \ifdefstring
here without adding the extra row?
I suspect etoolbox either (a) has a bug (missing some %
), or (b) is inserting something like \relax
. Is there some way to discard/eat \ifdefstring
's seemingly invisible-yet-row-creating output?