
ほとんどのスタイル ファイルでは、author コマンドと title コマンドが少し異なる必要があり、スタイル ファイルを簡単に変更できるようにしたいため、author コマンドと title コマンドにメタレベルを実装しようとしました。
簡単に言うと、amsart
マクロを に挿入すると、クラスが奇妙な動作をすることに気づきました\title{}
。エラーは発生しませんが、タイトルが大文字になりません。ただし、太字のままになります。
つまり、効果なしもすべての効果もありません。また、\expandafter
考えられるすべての場所に配置しようとしましたが、どうやらこのコマンドをあまり理解していないようです。
\documentclass[a4paper,reqno]{amsart}
\usepackage[utf8]{inputenc}
\begin{document}
\newtoks\mytitleA
\mytitleA={This is a title}
\newcommand{\mytitle}{This is a title}
\newcommand{\myauthor}{This is me}
% toggle the following commands to see that only the last version
% produceses the correct layout
%\title{\the\mytitleA}
%\title{\mytitle}
\title{This is a title}
% for the author I cannot spot a difference
\author{\myauthor}
\author{This is me}
\maketitle
\end{document}
のような他のスタイル ファイルでは、article
タイトルのタイプセットが異なっているようには見えませんが、マクロ内にネストされている場合、少なくとも違いはわかりませんでした。したがって、またはamsart
の実装に問題がある可能性があります。\title{}
\maketitle
これを修正する方法、または少なくともネストされたマクロを機能させる方法はありますか?
答え1
一つ忘れてたする仕事、すなわち
\expandafter\title\expandafter{\the\mytitleA}
もちろん、レジスターの内容を配信するために必要なので、\the
前を避けることは何も\mytitleA
機能しません。\the
\toks
何が問題なのでしょうか? デフォルトでamsart
は を使用します\uppercase
(そうすべきではありませんが、それは別の問題です)。
textcase
を強制amsart
的に使用して、その作業の\MakeTextUppercase
前に完全な (保護された) 展開が行われるようにロードすることで、この問題を回避できます。\uppercase
\toks
レジスター付き
\documentclass[a4paper,reqno]{amsart}
\usepackage{textcase}
\newtoks\mytitleA
\mytitleA={This is a title}
\newcommand{\myauthor}{This is me}
\begin{document}
\title{\the\mytitleA}
\author{\myauthor}
\maketitle
\end{document}
コマンドで
\documentclass[a4paper,reqno]{amsart}
\usepackage{textcase}
\newcommand{\mytitle}{This is a title}
\newcommand{\myauthor}{This is me}
\begin{document}
\title{\mytitle}
\author{\myauthor}
\maketitle
\end{document}