
편집됨: David Carlisle은 친절하게도 \makeatletter 다음에 정의된 댓글로 답변을 제공했습니다.
\NewDocumentCommand의 장식을 사용하여 \Gamma의 첨자를 커닝하는 매크로를 정의하려고 합니다(보다 일반적인 문제에 대한 테스트 케이스로). 소수를 처리하는 방법을 모르겠습니다. 그들은 인수를 취하지 않기 때문에 아래에 주석이 달린 두 가지 버전을 시도했지만 두 경우 모두 마지막 예에서 _는 더 이상 장식으로 처리되지 않습니다. 이 문제를 해결할 수 있는 방법이 있나요?
\documentclass{article}
\NewDocumentCommand{\kernedGamma}{e{^_}}{\Gamma\IfValueT{#1}{^{#1}}\IfValueT{#2}{_{\mkern-3mu #2}}}
%\NewDocumentCommand{\kernedGamma}{e{^_'}}{\Gamma\IfValueT{#1}{^{#1}}\IfValueT{#2}{_{\mkern-3mu #2}}\IfValueT{#3}{^{\prime}#3}}
%\NewDocumentCommand{\kernedGamma}{e{^_}t'}{\Gamma\IfValueT{#1}{^{#1}}\IfValueT{#2}{_{\mkern-3mu #2}}\IfBooleanT{#3}{^{\prime}}}
\makeatletter
\RenewDocumentCommand{\kernedGamma}{e{^_}t'e{_}}{\Gamma\IfValueT{#1}{^{#1}}
\IfValueT{#2}{_{\mkern-3mu #2}}\IfBooleanT{#3}{^{\prime}}
\IfValueT{#4}{\IfValueT{#2}{\@latex@error{embellishment used twice}}_{\mkern-3mu #4}}}
\makeatother
\begin{document}
$\Gamma_1$ $\kernedGamma_1$
$\Gamma^2_2$ $\kernedGamma^2_2$
$\Gamma_1'$ $\kernedGamma_1'$
$\Gamma'_1$ $\kernedGamma'_1$
\end{document}
답변1
사용e{^_}t'e{^_}
\documentclass{article}
\NewDocumentCommand{\kernedGamma}{e{^_}t'e{^_}}{%
\kernedGammaAux{#1}{#2}{#3}{#4}{#5}%
}
\ExplSyntaxOn
\NewDocumentCommand{\kernedGammaAux}{mmmmm}
{
\bourke_kernedGamma:nnnnn { #1 } { #2 } { #3 } { #4 } { #5 }
}
\cs_new_protected:Nn \bourke_kernedGamma:nnnnn
{%#1 = first sup, #2 = first sub, #3 = prime, #4 = second sup, #5 = second sub
\Gamma
\bool_if:nTF { #3 }
{% there's a prime
\sp{ \tl_if_novalue:nF { #1 } { #1 } \prime \tl_if_novalue:nF { #4 } { #4 } }
}
{%
\exp_args:Ne \tl_if_empty:nF { \__bourke_double:nn { #1 } { #4 } }
{
\sp{ \__bourke_double:nn { #1 } { #4 } }
}
}
\sb{ \mkern -3mu ~ \__bourke_double:nn { #2 } { #5 } }
}
\cs_new:Nn \__bourke_double:nn
{
\tl_if_novalue:nF { #1 } { \exp_not:n { #1 } }
\tl_if_novalue:nF { #2 } { \exp_not:n { #2 } }
}
\ExplSyntaxOff
\begin{document}
$\kernedGamma$ $\Gamma$
$\kernedGamma'$ $\Gamma'$ $\Gamma^{\prime}$
$\kernedGamma'^{2}_{i}$ $\Gamma'^{2}_{i}$
$\kernedGamma_{i}^{2}'$ $\Gamma^{2\prime}_{i}$
$\kernedGamma_{i}'^{2}$ $\Gamma'^{2}_{i}$
$\kernedGamma_{i}^{2}$ $\Gamma^{2}_{i}$
\end{document}
(사진은 나중에 Imgur에서 허용하면 추가하겠습니다)