Text Formatting\textsc in \edef

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
zvonsully
Posts: 3
Joined: Sun Jan 09, 2011 4:50 am

\textsc in \edef

Post by zvonsully »

The following simple code gives errors. I need edef so I can build a list of words by redefining \test. The \textsc command seems to be the problem...

Code: Select all

\documentclass{article}

\begin{document}

\edef\test{\textsc{a}}
% \edef\test{\test b}
% \edef\test{\test c}
 
\test

\end{document} 

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

\textsc in \edef

Post by sommerfee »

You need to use some macro which concatenate the content without expanding it, for example \g@addto@macro:

Code: Select all

\documentclass{article}

\makeatletter
\newcommand\addtotest[1]{\g@addto@macro\test{#1}}
\newcommand\test{}
\makeatother

\begin{document}

\addtotest{\textsc{a}}
\addtotest{b}
\addtotest{c}

\test

\end{document} 
Post Reply