For convenience (and also to deepen my LaTeX knowledge), I'm trying to define a list in a simple manner: \mylist(First, Second, Third, ...)
Replacing the commas by something else (in this case by \texttt{,} works, but I have trouble to convert the ellipsis at the end. When there is a single dot in any part, my solution brakes.
This is my MWE:
\documentclass[a4paper]{article} \makeatletter \def\mylist (#1){% \begingroup% \begingroup\lccode`~=`, \lowercase{\endgroup\def~}{\texttt{,} }% \begingroup\lccode`~=`. \lowercase{\endgroup\def~~~}{\texttt{...}}% \catcode`,=\active% \catcode`.=\active% \texttt{(}\scantokens{#1}\texttt{)}% \endgroup% }% \makeatother \begin{document} % This works: \mylist(First, Second, Third, ...) % This should always work: Some text with ... dots ... that \ldots should not be changed. Dots in \textbf{.} commands should also work. % This does not work: % Expected: \texttt{(}First\texttt{,} Second\texttt{, } Th.rd\texttt{, }\texttt{...}\texttt{)} % Error: ! Use of . doesn't match its definition. \mylist(First, Second, Th.rd, ...) \end{document} Also, if you have any other suggestions for improvements, feel free to tell me.


\textellipsisfor the three dots? Or, if you are compiling with a utf8-aware engine (such aslualatexyou can simply past the ellipsis from a character map....is because it is the most natural way for me to write an incomplete list. Also, I'd like to understand how I could do it to deepen my understanding of TeX.\ldots.active it is hard not to break some uses in numbers etc, if you keep it restricted to the list macro and never use that macro in the argument of any other command and never have any math or lengths inside the list then it's perhaps safe enough, but that's a lot of ifs to use a syntax that will confuse any human readers of the source and confuse some conversions to html etc.