I have some short text (book author names) stored in a sequence. Some author names are long, and therefore I have to insert manually a line break (\\). In a specific case, I have to typeset these names completely lowercase.
Thanks to the help of Joseph Wright, the LowerCase works fine with text that contains the paragraph breaks (\\).
But now, I store the text in a sequence \g_sbmcpm_listofauthors_seq and then I create a new sequence with the lowercased text \g_sbmcpm_listofauthors_lowercase_seq using \seq_map_function:NN.
When I try to print the names with \seq_use:Nn I get compilation errors.
If the names don't have \\ it works fine. But if there are some \; it only works when the string containing the \\ token is in the last position of the sequence.
(It doesn't matter if I use \\, \par or \newline). I get an error message like this
! Undefined control sequence.
<inserted text> ... }{Author NameOne \\ TooLong}\\
\__xparse_start_expandable...
l.54 \printauthorslowercase
If instead of \\ in the \seq_use:Nn, I use a ; character the error looks like this:
! Undefined control sequence.
<argument> \\
l.54 \printauthorslowercase
Below is the complete code:
\documentclass{article}
\usepackage{xparse}
\usepackage{tikz}
\ExplSyntaxOn
\NewDocumentCommand \LowerCase { m }
{
\cs_set_eq:NN \__texnik_newline: \\
\cs_set_protected:Npx \\ { \exp_not:o \\ }
\tl_lower_case:n {#1}
\cs_set_eq:NN \\ \__texnik_newline:
}
\cs_new:Npn \add_lowerauthor #1
{
\tl_set:No \l_tmpa_tl {\LowerCase{#1}}
\seq_gput_right:No \g_sbmcpm_listofauthors_lowercase_seq {\l_tmpa_tl}
\seq_log:N \g_sbmcpm_listofauthors_lowercase_seq
}
\seq_new:N \g_sbmcpm_listofauthors_seq
\DeclareDocumentCommand{\mainauthor} {m} {%
\seq_put_right:Nn \g_sbmcpm_listofauthors_seq {#1}
}
\seq_new:N \g_sbmcpm_listofauthors_lowercase_seq
\NewDocumentCommand \printauthorslowercase { }
{
\seq_map_function:NN \g_sbmcpm_listofauthors_seq \add_lowerauthor
\seq_use:Nn \g_sbmcpm_listofauthors_lowercase_seq {;}
}
\ExplSyntaxOff
%% This works
% \mainauthor{Author NameOne}
% \mainauthor{Author NameTwo}
%%% This also works
% \mainauthor{Author NameOne}
% \mainauthor{Author NameTwo \\ TooLong}
%%% This doesn't works
\mainauthor{Author NameOne \\ TooLong}
\mainauthor{Author NameTwo}
\begin{document}
\begin{tikzpicture}[overlay, remember picture]
\node[align=left] (text1)
{%
\printauthorslowercase
};
\end{tikzpicture}
\end{document}
\\only works if it is the last one, your data which you state works, has\\in the last entry, the other one does not. Why even the need for manual break, why not use\raggedright? – daleif Feb 16 '18 at 11:53