# expl3: lowercase sequence elements with line break breaks

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

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

• Observation: the entry with \\ 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
• I rewrite a bit to make it clearer I hope :-). These macros are used to produce book covers, where I need total control of where the line breaks are inserted. – TeXtnik Feb 16 '18 at 13:27

I'm not sure I follow, but I don't see problems in passing \\ to \tl_lower_case:n.

\documentclass{article}

\usepackage{xparse}
\usepackage{tikz}

\ExplSyntaxOn

\NewDocumentCommand{\mainauthor} {m}
{
\seq_put_right:Nn \g_sbmcpm_listofauthors_seq {#1}
}

\NewDocumentCommand \printauthorslowercase { }
{
\seq_use:Nn \l_sbmcpm_listofauthors_lowercase_seq  {;}
}

\seq_new:N \g_sbmcpm_listofauthors_seq
\seq_new:N \l_sbmcpm_listofauthors_lowercase_seq

{
\seq_put_right:Nn \l_sbmcpm_listofauthors_lowercase_seq { \tl_lower_case:n {#1} }
}

\ExplSyntaxOff

\mainauthor{Author NameOne \\ TooLong}
\mainauthor{Author NameTwo}

\begin{document}

\begin{tikzpicture}[overlay, remember picture]
\node[align=left] (text1)
{%
\printauthorslowercase
};
\end{tikzpicture}

\end{document}

• If you follow the link of the previous question (at the top) and then another link to a previous question :-); Joseph said that "The only issue is that \ is not engine robust and the implementation of \tl_lower_case:n expects 'text' to be either character tokens, things which expand to character tokens or engine-robust command". HIs answer dates back to Sep 1, 2016. At that time it didn't work. Has the implementation of \tl_lower_case:n change? – TeXtnik Feb 16 '18 at 13:35
• Dear egreg, I took some much time to accept your answer because, even your solution was working fine in the MWE, it was failing in real case. I am using the bookcover class, but when I load the pst-barcode package, the document breaks. I managed to remove the dependency of pst-barcode; so now my problem is fixed. – TeXtnik Mar 2 '18 at 9:30