# Preserving the mixed-case of a word within a set of words that was previously set in title case

In the URL removing the first character in a combination of strings and commands/tokens using \gobblechar of stringstrings, @JosephWright has suggested the command \ExplTitlecase (expl3) to capitalize the first word of a set of words set in lowercase.

In the following MWE, I have used Joseph Wright's \ExplTitlecase. I have shown Examples 1 to 4.

%MWE
\documentclass{article}
\newcommand*{\myMixedCaseCommand}[1]{#1}
\ExplSyntaxOn
\NewExpandableDocumentCommand{\ExplTitlecase}{m}
{
\text_titlecase:n { #1 }
}
\ExplSyntaxOff

\begin{document}
%Example 1
\ExplTitlecase{first word will be capitalized}

%Example 2
\ExplTitlecase{a certain \uppercase{UPPERCASE} acronym within a set of words set in lowercase}

%Example 3
\ExplTitlecase{a certain \lowercase{lowercase} acronym within a set of words set in lowercase}

%Example 4
\ExplTitlecase{a certain \myMixedCaseCommand{MiXeDCaSe} acronym within a set of words set in lowercase}
\end{document}


The MWE compiles fine, and the output in Examples 1 to 3 are expected. However, what I would want for Example 4 is to find some kind of command, which I temporarily call \myMixedCaseCommand, such that this command preserves the mixed-case nature of the acronym MiXeDCaSe. In the output, MiXeDCaSe was lowercased and became mixedcase. I would want the output to be exactly MiXeDCaSe.

Kindly seeking any help.

You can add to the list of commands that should not have their argument acted on by the process.

\documentclass{article}

\NewDocumentCommand{\myMixedCaseCommand}{m}{#1}

\ExplSyntaxOn

\NewExpandableDocumentCommand{\ExplTitlecase}{m}
{
\text_titlecase:n { #1 }
}
% add \myMixedCaseCommand to the exclusion list
\tl_put_right:Nn \l_text_case_exclude_arg_tl { \myMixedCaseCommand }

\ExplSyntaxOff

\begin{document}

%Example 1
\ExplTitlecase{first word will be capitalized}

%Example 2
\ExplTitlecase{a certain \uppercase{UPPERCASE} acronym within a set of words set in lowercase}

%Example 3
\ExplTitlecase{a certain \lowercase{lowercase} acronym within a set of words set in lowercase}

%Example 4
\ExplTitlecase{a certain \myMixedCaseCommand{MiXeDCaSe} acronym within a set of words set in lowercase}

\end{document}


• thank you sir @egreg. it worked. Jul 25 at 9:59
• it is an exclusion list. so we can just add any number of commands separated by space or newline that we want excluded? Jul 25 at 10:01
• @beethovengg14 Yes, you can add any number of robust commands. Jul 25 at 10:26
• thank you. i think im beginning to be interested with this expl3 thing, i just have no reference materials to read now. thanks again Jul 25 at 10:37
• kindly seeking again your help. tex.stackexchange.com/questions/606822/… Jul 28 at 16:34