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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
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