KTUG 한국 텍 사용자 그룹

Menu

KTUG :: 마당정보글 › 매크로 또는 파일이 존재한다면

yihoze | 2015.06.23 11:23:50 | 메뉴 건너뛰기 쓰기

\Ifexist*{\accessories}{accessories}{\pinput{accessories}}

  1. \accessories가 정의되어 있다면 그 내용이 식자된다.
  2. 그것이 정의되어 있지 않다면---현재 디렉토리에 accessories.tex 파일이 있다면 그것을 삽입한다.
  3. 그 파일이 존재하지 않는다면, 특정한 경로에서 accessories.tex 파일을 가져온다.

\newcommand\Ifexist{\@ifstar{\IfFileExist}{\IfMacroExist}}

\newcommand\IfMacroExist[2]{\ifthenelse{\isundefined{#1}}{#2}{#1}}

\newcommand\IfFileExist[3]{%

\ifthenelse{\isundefined{#1}}%

{\InputIfFileExists{#2}{}{#3}}%

{#1}}

\NewEnviron{IfExist}[1]{\IfMacroExist{#1}{\BODY} }

\NewEnviron{IfExist*}[2]{\IfFileExist{#1}{#2}{\BODY} }


\newcommand\rootpath{../../Common/}
\newcommand\setrootpath[1]{\renewcommand\rootpath{#1}}
\newcommand\langpath{}
\newcommand\setlangpath[1]{\renewcommand\langpath{\rootpath#1}}
\newcommand\pinput{\@ifstar{\rootinput}{\langinput}}
\newcommand\rootinput[1]{\input{\rootpath#1}}
\newcommand\langinput[1]{\input{\langpath#1}}

댓글 쓰기

목록

KTUG 한국 텍 사용자 그룹