3

When I run this MWE

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}

\usepackage{ifthen}
\usepackage{xifthen}
\usepackage{etoolbox}

\newcommand{\Entry}[6][\textwidth-3cm-16pt]{        %% new entry
\parbox[t]{#1}{%
    \ifthenelse{ \equal{#3}{}           }{}{\textbf{#3}}%
    \ifthenelse{ \equal{#4}{}           }{}{\ifthenelse{\equal{#3}{}}{}{\headdelimiter}{#4}}
    \ifthenelse{ \equal{#5}{}           }{}{\hfill\slshape#5\upshape\hspace{-7mm}}%
    \ifthenelse{ \equal{#5}{}\OR\equal{#6}{}            }{}{\hspace{-7mm}\\[-3.0mm]{\color{colI!20}\rule[2pt]{#1}{0.5pt}}\vspace{-6.0mm}}%
    \ifblank{#6}                        {}{
        \begin{itemize}
            #6
        \end{itemize}
    }
}
}

\begin{document}

\Entry{D}{A}{B}{C}{
    \item asdf
}

\Entry{D}{A}{B}{C}{}

\end{document}

I get the error

Incomplete \iffalse; all text was ignored after line 26

I have no idea what I am doing wrong. Can someone help?

0

2 Answers 2

4

One problem is that \item appears in the 5th argument, which is not meant, actually it is meant for the 6th argument, thereby a stray \item outside of list occurs.

I prefer etoolbox rather than ifthen and checking with \ifblank whether the argument is empty, or not.

\documentclass[a4paper,10pt]{article}

\usepackage[utf8]{inputenc}

\usepackage{etoolbox}


\newcommand{\Entry}[6]{%
  \ifblank{#5}{}{#5}
  \ifblank{#6}{}{%
    \begin{itemize}
      #6
    \end{itemize}
  }
}

\begin{document}

\Entry{D}{A}{B}{C}{}{%
\item asdf
}

\Entry{D}{A}{B}{C}{}{}

\end{document}

A variant with optional arguments

\documentclass[a4paper,10pt]{article}

\usepackage[utf8]{inputenc}

\usepackage{xparse}


\NewDocumentCommand{\Entry}{+m+m+m+m+o+d<>}{%
  \IfValueT{#5}{#5}
  \IfValueT{#6}{%
    \begin{itemize}
      #6
    \end{itemize}
  }%
}

\begin{document}

\Entry{D}{A}{B}{C}<%
\item asdf
>

\Entry{D}{A}{B}{C}[E]<\item And now for something completely different>

\end{document}
3
  • I am sorry, I think by trying to make the MWE even more minimal I made some mistakes. I updated the MWE.
    – Make42
    Jan 15, 2018 at 13:12
  • 1
    @Make42: Yes, that means totally screwing up my answer ... :-(
    – user31729
    Jan 15, 2018 at 13:13
  • Sorry for that! However, I am not sure that your answer got completely screwed up. I did not mix up the parameter positions, but otherwise the error stays the same. Using \ifblank does not work, but I don't see why it should have before if it does not now. The issue is still with #6 and how to deal with \item when asking for equal.
    – Make42
    Jan 15, 2018 at 13:32
3

Try this code:

\documentclass{article}
\usepackage{calc}
\newcommand{\Entry}[6][\textwidth-3cm-16pt]{
\parbox[t]{3cm}{#2}%
\parbox[t]{#1}{%
    \ifx#5\relax\else\hfill\slshape#5\upshape\hspace{-7mm}\fi%
    \ifx#6\relax\else
        \begin{itemize}
            #6
        \end{itemize}
    \fi
    }
}
\begin{document}
\Entry{D}{A}{B}{}{
\item asdf
}

\Entry{D}{A}{B}{C}{}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .