我看过答案了这里适用于 Latex。我怎样才能将其适配到普通 TeX 或 OPTeX?
\frlang
\fontfam[Times]
{
\catcode`\:=\active
\catcode`\;=\active
\catcode`\?=\active
\catcode`\!=\active
\catcode`\«=\active
\catcode`\»=\active
\gdef\frenchpunct{%
\catcode`\:=\active \def:{\thinspace\char`\: }
\catcode`\;=\active \def;{\thinspace\char`\; }
\catcode`\?=\active \def?{\thinspace\char`\? }
\catcode`\!=\active \def!{\thinspace\char`\! }
\catcode`\«=\active \def«{\thinspace\char`\« }
\catcode`\»=\active \def»{\thinspace\char`\» }
}
}
\def\nofrenchpunct{%
\catcode`\:=12
\catcode`\;=12
\catcode`\?=12
\catcode`\!=12
\catcode`\«=12
\catcode`\»=12
}
\frenchpunct
bonjour: monde; oui? non! «aujourd'hui» % opening « does not work, but closing -- » -- does.
\nofrenchpunct
bonjour: monde; oui? non! «aujourd'hui»
\bye
答案1
你已经快到了,但空间应该后开幕式。
我还添加了\unskip
或\ignorespaces
以支持传统的法语输入方式。
\frlang
\fontfam[Times]
\begingroup
\catcode`\:=\active
\catcode`\;=\active
\catcode`\?=\active
\catcode`\!=\active
\catcode`\«=\active
\catcode`\»=\active
\gdef\frenchpunct{%
\catcode`\:=\active \def:{\unskip\thinspace\char`\: }
\catcode`\;=\active \def;{\unskip\thinspace\char`\; }
\catcode`\?=\active \def?{\unskip\thinspace\char`\? }
\catcode`\!=\active \def!{\unskip\thinspace\char`\! }
\catcode`\«=\active \def«{\char`\«\thinspace\ignorespaces}
\catcode`\»=\active \def»{\unskip\thinspace\char`\» }
}
\endgroup
\def\nofrenchpunct{%
\catcode`\:=12
\catcode`\;=12
\catcode`\?=12
\catcode`\!=12
\catcode`\«=12
\catcode`\»=12
}
\frenchpunct
bonjour: monde; oui? non! «aujourd'hui»
bonjour : monde ; oui ? non ! « aujourd'hui »
\nofrenchpunct
bonjour: monde; oui? non! «aujourd'hui»
\bye