1

A few weeks ago (like maybe 5?) \@currname worked fine. Then I guess I updated MikTeX, which I do pretty often, and now it doesn't. MWE:

% scrap.sty
\title{1\@currname2}

% scrap.tex
\documentclass{article}
\usepackage{scrap}
\begin{document}
\maketitle
\end{document}

The title ends up as 12. Am I doing something wrong here?

5
  • What did \@currname output previously? Perhaps you're looking for \jobname?
    – Werner
    Jul 9, 2016 at 3:59
  • The name of the style file.
    – Mark
    Jul 9, 2016 at 4:02
  • According to source2e, it is set by \@onefilewithoptions. Presumably it is called by \usepackage. Jul 9, 2016 at 4:21
  • I had to update MikTeX two times in a row to make it work properly. Maybe this works. Jul 9, 2016 at 7:06
  • I am feeling silly. Werner was right. Everything is working after all.
    – Mark
    Jul 9, 2016 at 7:56

1 Answer 1

3

The default consequence of writing \title{<stuff>} results in <stuff> being stored inside \@title, which is eventually used by \maketitle. Moreover, <stuff> is not expanded at all, so using a macro that changes based on context may result in an unwanted outcome.

Ways around this could be to explicitly expand \@currname as part of the title. Two ways are:

\xdef\@title{1\@currname2}

or

\begingroup\edef\x{\endgroup\noexpand\title{1\@currname2}}\x

enter image description here

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents*}{scrap.sty}
%\xdef\@title{1\@currname2}% Option 1
\begingroup\edef\x{\endgroup\noexpand\title{1\@currname2}}\x% Option 2
\end{filecontents*}

\usepackage{scrap}

\begin{document}
\maketitle
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .