I am trying to display some information in a \cventry conditionally using a defined \ifdetails switch. However, for some reason that is beyond my knowledge, an spurious space (or new line) is created.
I tested this using \newtoggle from etoolbox and the same happens. Not sure if it has to do with the definition of the \cventry itself, or with the conditionals as macros.
Also, notice the strange behavior on the \ifdetails. If I put a % to protect the change of line after the brace, I need to \protect the \ifdetails. However, if I don't put that % it is not required.
Can someone explain what is the problem? And how can I eliminate the spurious white space?
\documentclass{moderncv}
\moderncvtheme[blue]{classic}
\firstname{Some}
\familyname{Dude}
\title{CV}
\newif\ifdetails
%\detailstrue
\detailsfalse
\begin{document}
\maketitle
\section{Using cventry:}
\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{
\ifdetails% if not using a % before, I don't need to protect
I would like all this stuff to be raggedright, however. The "year-year" is not important.
\fi
}
\cventry{year--year}{THIS IS JUSTIFIED, AS YOU CAN PLAINLY SEE}{THIS IS ALSO JUSTIFIED}{THIS IS JUSTIFIED, TOO}{AND THIS IS JUSTIFIED AS WELL}{%<- if using this, I need to \protect below
\protect\ifdetails%
I would like all this stuff to be raggedright, however.
% This more complex content breaks existing solutions
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\fi%
}
\end{document}
What I get:

What I want:

Edit: I added the itemize environment on the contents to show that it breaks solutions.

\detailstrueand the%after the opening brace, the code doesn't work. And if one does not uses the%then a spurious space appears. Any thoughts? – adn Jul 23 '15 at 17:39\detailstrueand no%after the opening brace (not in the definition, but in the\cventryuse), I don't get a spurious space. – Werner Jul 23 '15 at 17:54%after the brace it doesn't. (Like this one) – adn Jul 23 '15 at 18:01#7in the\ifcondition to avoid mis-interpretation of the\fiin\ifdetails...\fi. – Werner Jul 23 '15 at 18:06\argseven... – Werner Jul 24 '15 at 18:52itemizeenvironment with the details it doesn't work. :( – adn Jul 27 '15 at 13:19itemize? – adn Jul 29 '15 at 14:58moderncv) and ask a new question. – Werner Jul 29 '15 at 16:58