도움말: 물건을 보관하기 위한 일반적인(그리고 우아한) 배열(변수) 맵 구문을 찾고 있습니다.

도움말: 물건을 보관하기 위한 일반적인(그리고 우아한) 배열(변수) 맵 구문을 찾고 있습니다.

이 내용이 다른 곳에서 논의되었다면 사과드립니다. 하지만 그렇다면 찾을 수 없었습니다.

저는 대학에서 학술 논문 템플릿을 작성했지만 확실히 TeX 전문가는 아닙니다. 이 템플릿에서는 임시(자체) 정의 배열 맵을 사용하는 구성 파일을 광범위하게 사용합니다. 예:

\arraymay{cover}
\cover{phd}={phd_cover_file.pdf}
\cover{msg}={msc_cover_file.pdf}
\arraymap{margin}
\margin{cover,left}={5cm}
\margin{cover,right}={5cm}
\margin{cover,top}={4cm}
\margin{cover,bottom}={4cm}
\margin{main,left}={3cm}
\margin{main,right}={3cm}
\margin{main,top}={2cm}
\margin{main,bottom}={2cm}

키의 쉼표는 시각적 효과를 위해 사용되며 일반 문자로 간주됩니다. 즉, " \margin{cover,bottom}={2cm}"에서 키는 " cover,bottom"입니다.

나중에 다음과 같이 값에 액세스할 수 있습니다.

\def\manuscripttype{phd}
The cover file is ``\thecover[\manuscripttype]'' and the margins for the cover are ``\themargin[cover,left], \themargin[cover,right], \themargin[cover,top], and \themargin[cover,bottom].''

생산할 것이다

The cover file is “phd_cover_file.pdf” and the margins for the cover are “3cm, 3cm, 2cm, and 2cm.”

이 기능을 구현하는 다른 (단단한) 패키지가 있습니까? 그렇지 않다면 이를 구현할 수 있는 확실한 방법이 있습니까(KV 패키지 중 하나를 기반으로 할 수도 있음)? 감사해요.

답변1

당신은 그것을 할 수 있습니다 pgfkeys:

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage{pgfkeys}

\pgfkeys{
  lourenco/.cd,
  cover/phd/.initial={},
  cover/msc/.initial={},
  margin/cover/left/.initial=0pt,
  margin/cover/right/.initial=0pt,
  margin/cover/top/.initial=0pt,
  margin/cover/bottom/.initial=0pt,
  margin/main/left/.initial=0pt,
  margin/main/right/.initial=0pt,
  margin/main/top/.initial=0pt,
  margin/main/bottom/.initial=0pt,
}

\newcommand{\setlourenco}[1]{\pgfkeys{lourenco/.cd,#1}}
\newcommand{\thecover}[1]{%
  \pgfkeysvalueof{/lourenco/cover/#1}%
}
\newcommand{\themargin}[1]{%
  \pgfkeysvalueof{/lourenco/margin/#1}%
}

%% settings
\setlourenco{
  cover/phd=phd-cover-file.pdf,
  cover/msc=msc-cover-file.pdf,
  margin/cover/left=5cm,
  margin/cover/right=5cm,
  margin/cover/top=4cm,
  margin/cover/bottom=4cm,
  margin/main/left=3cm,
  margin/main/right=3cm,
  margin/main/top=2cm,
  margin/main/bottom=2cm,
}

\def\manuscripttype{phd}

\begin{document}

The cover file is ``\thecover{\manuscripttype}'' and the margins 
for the cover are ``\themargin{cover/left}, \themargin{cover/right},
\themargin{cover/top}, and \themargin{cover/bottom}.''

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보