Re: 引数の数や内容を判断するマクロの作成

名前: 本田
日時: 2006-10-20 12:49:00
IPアドレス: 219.118.112.*

>>45577 >\newcommand{\plot}[5][htbp]{% > \begin{figure}[#1] > \centering > \includegraphics[#3]{#2} > \caption[#5]{#4} > \label{fig:#2} > \end{figure} >} こういうマクロはソースの視認性と可読性を 著しく下げるので使わないのにこしたことはないのですが.. #少なくとも投稿論文や出版原稿の類いでは事故の原因 \@ifnexrchar などを調べてください. 引数が空白か否かの判別はしていません. \def\plot{\@ifnextchar[{\@plot}{\@plot[htbp]}} \@def\@plot[#1]#2#3#4{% \@ifnextchar[{\@@plot{#1}{#2}{#3}{#4}}% {\@@plot{#1}{#2}{#3}{#4}[]}} \def\@@plot#1#2#3#4[#5]{% \begin{figure}[#1] \centering \includegraphics[#3]{#2} \caption[#5]{#4} \label{fig:#2} \end{figure}% \ignorespaces} \plot[htbp] {hoge.eps} {width=\textwidth} {長いキャプション} [短いキャプション] \plot[htbp] {hoge.eps} {width=\textwidth} {長いキャプション}

この書き込みへの返事:

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