활성 문자의 콜백 교체

활성 문자의 콜백 교체

LuaLaTeX, TeXlive 2024, Linux를 사용합니다.

편집: David가 쓴 것처럼 허용된 답변에서는 Lua 콜백이 필요하지 않습니다. 하지만 다른 사용자가 ".

내 지원서에는 텍스트(수학이나 다이어그램이 아님)가 포함되어 있습니다. 인간 편집자와 일반 텍스트 파일을 교환하는데 가끔 이상한 사람 "이 들어옵니다. 큰따옴표는 영어 대화에서 널리 사용됩니다. TeX이 처리하는 방식은 "(편집자가 사용하는) 워드 프로세서가 처리하는 방식과 다릅니다.

TeX 합자는 항상 "오른쪽 큰따옴표로 설정됩니다. 내가 원하는 것이 아닙니다. 목록 "에서 제거할 수는 있지만 tlig그것만으로는 충분하지 않습니다. 내가 하고 싶은 것은 "마주칠 때마다 메시지를 쓰는 것이다. 그런 다음 그 "자리에 그대로 두세요(곱슬머리 아님).

"활동적인 캐릭터를 만들어서 메시지를 쓸 수 있어요 . 하지만 그 "자리를 떠날 수는 없습니다 . 왜냐하면 그것은 무한대로 이어지기 때문입니다.

활성 문자를 "해당 목적을 위해 내가 만든 다른 유니코드 문자, 즉 ". 이렇게 하면 문제가 (거의) 해결됩니다. 메시지를 쓸 수 있고 종이에 인쇄하면 메시지 "가 보입니다. 그러나 대체 캐릭터는 실제로 로봇이 아니기 때문에 "PDF 검사관이 이를 표시할 수 있습니다. 이는 TeX의 범위를 벗어납니다.

다양한 부분의 코드를 살펴보면 콜백을 통해 문자 모양 대체를 허용하는 메서드가 texmf-dist/tex/luatex있다는 것을 알 수 있습니다 . something.sub나에게 꼭 필요한 것 같군요. 아아, 나는 그것을 사용하는 방법을 분별할 수 있는 프로그래머가 충분하지 않습니다.

MWE:

\documentclass{article} % compile with lualatex
\usepackage{fontspec}
\begin{document}
\catcode`\"=13 % straight double quotes now active.
\def"{\typeout{EEEEEK}º} % message, and subtitute with something else.
Hello, "World."\par
% I used the degree symbol as substitute character, because they have
% similar metrics in Latin Modern Roman. In my own usage, I use a different
% character, specifically created for the purpose (custom font).
% That character is identical to " but at a different Unicode location.
% At this point I would like to use a Lua callback for the finished paragraph,
% and revert the substitute back to ".
I said, "Hello," previously.
% Do it again.
\end{document}

참고: 문서 본문에는 "바벨이나 폴리글로시아 단축키, 매크로 \char"HHHH, 수학이 필요하지 않습니다.

이전에 문자 대체를 위한 LuaLaTeX 사용에 대한 질문이 있었지만 기존 질문 중 활성 문자 관련 문제를 해결하는 질문은 없습니다.

답변1

LaTeX는 곧은 따옴표에 액세스하는 명령을 제공합니다

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

\documentclass{article} % compile with lualatex
\usepackage{fontspec}
\begin{document}
\catcode`\"=13 % straight double quotes now active.
\def"{\typeout{EEEEEK}\textquotedbl} % message, and subtitute with something else.
Hello, "World."\par
% I used the degree symbol as substitute character, because they have
% similar metrics in Latin Modern Roman. In my own usage, I use a different
% character, specifically created for the purpose (custom font).
% That character is identical to " but at a different Unicode location.
% At this point I would like to use a Lua callback for the finished paragraph,
% and revert the substitute back to ".
I said, "Hello," previously.
% Do it again.
\end{document}

관련 정보