Last active
January 17, 2019 14:04
-
-
Save astronasutarou/f6eff544e567bb12156b2b8f85a3f700 to your computer and use it in GitHub Desktop.
初回とそれ以降で評価される内容が異なるコマンドをつくる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[a4paper]{jsarticle} | |
\usepackage{xspace} | |
\usepackage{etoolbox,etextools} | |
\makeatletter | |
\newcommand*{\MyDefinition}[3]{% | |
\newtoggle{\string#1}% | |
\togglefalse{\string#1}% | |
\DeclareRobustCommand*#1{% | |
\@ifstar{\csname s\string#1\endcsname}{\csname n\string#1\endcsname}}% | |
\@namedef{s\string#1}{% | |
{#2\xspace}}% | |
\@namedef{n\string#1}{% | |
{\iftoggle{\string#1}{#3}{\global\toggletrue{\string#1}#2}}\xspace}} | |
\makeatother | |
\MyDefinition{\psf}{Point Spread Function (PSF)}{PSF} | |
\MyDefinition{\pfs}{Prime Focus Spectrograph (PFS)}{PFS} | |
\begin{document} | |
\section{\psf} | |
{\psf} \psf* \psf \psf \psf* | |
\subsection{\pfs} | |
{\pfs} \pfs* \pfs \pfs \pfs* | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment