를 사용하여 생성된 페이지 헤더 내부의 명령을 재정의하고 싶습니다 scrheading
. 그 이유는 페이지 헤더가 모두 낮은 대문자여야 하기 때문입니다. 그러나 장 헤더에는 내용을 변경하는 사용자 정의 명령이 포함되어 있습니다.글꼴 크기. 헤더 내부에서만 이 글꼴 크기 변경을 실행 취소해야 합니다.
MWE는 다음과 같습니다.
\documentclass{scrreprt}
\usepackage[markcase=lower]{scrlayer-scrpage}
\usepackage{graphics}
\usepackage{hyperref}
\newcommand*\lowsc[1]{\texorpdfstring{\protect\scalebox{0.8}{#1}}{#1}}
\pagestyle{scrheadings}
\automark[chapter]{chapter}
\renewcommand*\headfont{%
\scshape%
\renewcommand*\lowsc[1]{##1}}
\newcommand\itex{\lowsc{i}\textsc{tex}}
\begin{document}
\chapter{\itex{} test}
\clearpage
Some text. \itex{}.
\end{document}
여기서 예상되는 출력은 2페이지의 헤더가 다음과 같습니다.
대신 다음과 같습니다.
예제에서 \itex
볼 수 있듯이 \lowsc
매크로는 작은 대문자로 약어 스타일을 지정하기 위해 와 함께 사용되지만 \textsc
간헐적으로 소문자도 사용됩니다. 매크로 가 없으면 \lowsc
작은 대문자 옆에 너무 크게 보일 것입니다.
내부 \renewcommand*\lowsc
는 \headfont
아무런 영향을 미치지 않는 것 같습니다. 대신 \gdef
(또는 일부 사용자 정의 매크로)를 사용하면 \grenewcommand
작동합니다. 그러나 이는 명령을 재정의합니다.전 세계적으로, 따라서 본문의 후속 사용도 변경되어서는 안 됩니다. 이것은 나에게 범위 지정 문제처럼 보이지만 솔직히 내 (비 전역적으로) 재정의된 매크로가 적용되지 않는 이유를 완전히 알 수 없습니다.
답변1
을 정의한 방식으로 인해 \lowsc
헤더의 재정의는 아무 것도 적용되지 않습니다. 그 지점에서 TeX가 보는 것은 \lowsc
더 이상 가 아니라 이기 때문입니다 \scalebox{0.8}{i}
.
\DeclareRobustCommand
for를 사용하면 \lowsc
문제가 해결됩니다. 그러나 나는 조건부를 사용하겠습니다.
\documentclass{scrreprt}
\usepackage[markcase=lower]{scrlayer-scrpage}
\usepackage{graphics}
\usepackage{hyperref}
\newif\ifinheader
\DeclareRobustCommand\lowsc[1]{%
\ifinheader
#1%
\else
\texorpdfstring{\scalebox{0.8}{#1}}{#1}%
\fi
}
\pagestyle{scrheadings}
\automark[chapter]{chapter}
\renewcommand*\headfont{%
\scshape\inheadertrue
}
\newcommand\itex{\lowsc{i}\textsc{tex}}
\begin{document}
\chapter{\itex{} test}
\clearpage
Some text. \itex{}.
\end{document}