왜 \shorthandon과 \shorthandoff를 다른 매크로에 삽입할 수 없나요?

왜 \shorthandon과 \shorthandoff를 다른 매크로에 삽입할 수 없나요?

\title매크로를 둘러싸면 '의 언어('?', '!', ':' 및 ';' 앞에 공백이 추가됨) \shorthandon{;:!?}\shorthandoff{;:!?}예상되는 결과를 제공합니다 .babelfrench

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
%
\shorthandon{;:!?}%
\title{La crise? Quelle crise?}
\shorthandoff{;:!?}%
%
\begin{document}
\maketitle
\end{document}

\shorthandon그러나 매크로에 및 가 포함된 경우에는 작동하지 않습니다 \shorthandoff(재정의) \title.

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
%
\let\titleORI\title
\renewcommand{\title}[1]{%
  \shorthandon{;:!?}%
  \titleORI{#1}%
  \shorthandoff{;:!?}%
}
%
\title{La crise? Quelle crise?}
\author{Un auteur? Deux auteurs!}
%
\begin{document}
\maketitle
\end{document}

그 이유는 무엇입니까? 해결 방법이 있나요?

답변1

말하는 것은 활동적인 성격을 \shorthandon{?}만든다 . ?따라서 인수 to가 \title흡수되면 첫 번째 예에서는 활성화되고 에서 \maketitleLaTeX는 에 의해 정의된 현재 정의를 사용합니다 babel-french.

반대로, 두 번째 경우에는 \shorthandon인수가 \title이미 흡수되었을 때 명령이 실행되므로 ?활성화되지 않고 영원히 유지됩니다( 제목을 저장하는 \@title매크로인 의 대체 텍스트에서).\title

\shorthandon인수 가 실행된 후에는 인수 읽기를 지연해야 합니다 .

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}

\let\ORItitle\title
\renewcommand{\title}{%
  \shorthandon{;:!?}%
  \titlewithshorthand
}
\newcommand{\titlewithshorthand}[1]{%
  \ORItitle{#1}%
  \shorthandoff{;:!?}%
}

\title{La crise? Quelle crise?}

\begin{document}
\maketitle
\end{document}

그러나 나는 \title단순히 \begin{document}.

관련 정보