Quantcast
Channel: Active questions tagged starred-version - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 63

Using \protect to generalise definitions of starred commands?

$
0
0

This very helpful answer led me to define my own starred commands. However, in order to use my commands in, for example, headings, after a round of strange almost frightening thoughts, I managed to arrive at the following (MWE):

\documentclass{article}\makeatletter\def\testone{\@ifstar\@dothis\@@dothat}\def\testtwo{\protect\@ifstar\protect\@dothis\protect\@@dothat}\def\@dothis#1{#1}\def\@@dothat#1{#1}\makeatother\begin{document}\section{\testone{abc}} % does not work\testone{abc} % works\section{\testtwo{abc}} % works\testtwo{abc} % works\end{document}

I am still struggling to percolate TeX's expansion mechanisms and, hence, would be thankful for an answer about why my definition \test... requires these \protects to work in headings? Thanks.


Viewing all articles
Browse latest Browse all 63

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>