<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>[tex-eplain] \mark problem
solved</title></head><body>
<div>Hi everybody,<br>
</div>
<div>In certain situations, one needs the argument of \mark not be
expanded for some purposes and to be expanded for others. This occurs
for instance when one wants to automatically modify the headline
according to the title of the running section.</div>
<div>Then, we need the \noexpand in the \mark, but not in the regular
typeset.&nbsp; So we have to use the infamous LaTeX</div>
<div>\protect and redefine it according to the situation, for
instance:</div>
<div><br></div>
<blockquote>
<blockquote>\input eplain.tex<br>
\newtoks\runningtitle<br>
\headline={\hfil\the\runningtitle\hfil}<br>
\let\newtitlemark\relax<br>
<br>
\def\section#1#2{\mark{\par\newtitlemark\noexpand\else{#1\ #2}}<br>
&nbsp;&nbsp;&nbsp; \goodbreak\noindent {\let\protect\relax\bf\S\&nbsp;
#1\ $\,$#2}\smallskip<br>
&nbsp;&nbsp;&nbsp; \runningtitle={\iftrue\botmark\fi}<br>
&nbsp;&nbsp;&nbsp; \shortmark{#1\ #2}}<br>
\let\protect\noexpand<br>
<br>
\def\shortmark #1{\mark{#1\noexpand\else #1}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
\def\newtitlemark{#1}}<br>
<br>
\def\thmword{Theorem}<br>
\definexref{th1}{123}{thm}<br>
First<br>
\section{1}{Proof of \protect\ref{th1}}<br>
\null\vfil\eject<br>
Hey one, \ref{th1}.<br>
\mark{Hey, \noexpand\ref{th1}.}<br>
\null\vfil\eject<br>
ddd<br>
\par<br>
MARK \botmark<br>
\end<br>
</blockquote>
</blockquote>
<div>In all the marks, \ref gets stored unexpanded, but in the actual
title print, \protect is locally</div>
<div>redefined.</div>
<div><br></div>
<div>An alternative is to use the toks, eliminating the needs for any
\protect:</div>
<div><br></div>
<blockquote>\input eplain.tex</blockquote>
<blockquote>\newtoks\runningtitle</blockquote>
<blockquote>\headline={\hfil\the\runningtitle\hfil}</blockquote>
<blockquote>\let\newtitlemark\relax</blockquote>
<blockquote>\newtoks\title</blockquote>
<blockquote><br></blockquote>
<blockquote>\def\section#1#2{\title={#2}%</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp;
\mark{\par\newtitlemark\noexpand\else{#1\ \the\title}}</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; \goodbreak\noindent {\bf\S\&nbsp; #1\
$\,$#2}\smallskip</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp;
\runningtitle={\iftrue\botmark\fi}</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; \shortmark{#1\
\the\title}}</blockquote>
<blockquote><br></blockquote>
<blockquote>\def\shortmark #1{\mark{#1\noexpand\else #1}</blockquote>
<blockquote
>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
\def\newtitlemark{#1}}</blockquote>
<blockquote><br></blockquote>
<blockquote>\def\thmword{Theorem}</blockquote>
<blockquote>\definexref{th1}{123}{thm}</blockquote>
<blockquote>First</blockquote>
<blockquote>\section{1}{Proof of \ref{th1}}</blockquote>
<blockquote>\null\vfil\eject</blockquote>
<blockquote>Hey one, \ref{th1}.</blockquote>
<blockquote>\mark{Hey, \noexpand\ref{th1}.}</blockquote>
<blockquote>\null\vfil\eject</blockquote>
<blockquote>ddd</blockquote>
<blockquote>\par</blockquote>
<blockquote>MARK \botmark</blockquote>
<blockquote>\end</blockquote>
<div><br></div>
<div><br></div>
<div>Both these elegant solutions have been found by Stepan
Kasal.</div>
<div>Thanks again, Stepan!</div>
<div><br></div>
<div>Regards to everyone,</div>
<div><br></div>
<div>Gérald</div>
</body>
</html>