Re: マクロの組み合わせ

名前: Kay
日時: 2015-02-01 12:37:02
IPアドレス: 123.230.37.*

>>57599 昨日はありがとうございました。その後,本を読み, \expandafter\hantate\expandafter{\@year} ↓ 1つ目の \expandafter を実行。直後の \hantate が保留。 \hantate\expandafter{\@year} ↓ 2つ目の \expandafter を実行。直後の { が保留。 \hantate{2015} と理解しました。 # 最初,どうして2つめの \expandafter の後ろに1つしかないのか,わからなかった。 # {\@year} を1つとして数えるのではなく,{ と \@year として数えるのですね。 さて,もう1つ新しい質問ができました。\expandafter に気をつけて, \def\Vol#1{\expandafter\hantate\expandafter{#1}} \setcounter{section}{123} 第\Vol{\thesection}号 としたら,エラーになりました。 おそらく,カウンターが直接,数に変わるのではなく,別のマクロに展開されるから のように思うのですが,それ以上よくわかりません。 どのように修正すべきでしょうか。どなたかご教示ください。 \documentclass{utarticle} \usepackage[uplatex]{otf} \makeatletter \def\hantate#1{% \@tfor\@tempa:=#1\do{% \hspace{\kanjiskip}% \ifvmode \leavevmode \fi \iftdir% \hskip\kanjiskip% \hbox to1zw{\hss\hbox{\yoko\@tempa}\hss}% \hskip\kanjiskip\relax% \else \hbox{\@tempa}% \fi% }% } \def\Vol#1{% \expandafter\hantate\expandafter{#1}% } \makeatother \begin{document} %\setcounter{section}{123} % こちらを有効にすると, %第\Vol{\thesection}号 % \@@rensuji has an extra }. になる。 \newcounter{hoge}{135} % Argument of \@arabic has an extra }. になる。 \setcounter{hoge}{123} 第\Vol{\thehoge}号 \end{document}

この書き込みへの返事:

お名前
題名 
メッセージ(タグは <a href="...">...</a> だけ使えます。適宜改行を入れてください)