如何在纯 TeX 中对葡萄牙语进行连字符处理?

如何在纯 TeX 中对葡萄牙语进行连字符处理?

我想在葡萄牙语中使用纯 TeX,但我不知道如何在这种语言或英语以外的任何其他语言中使用连字符。我该怎么办?

答案1

使用 XeTeX 应该很简单:

\uselanguage{portuguese}
\font\test="Helvetica"
\hsize=1cm
\test
Tabelas de Hifenação
\bye

但如果由于某种原因该命令\uselanguage对您不可用,您可以尝试\language=18

答案2

我可以为 XeTeX 提出一个程序;有些也可以为 pdfTeX 完成,但需要一些时间。

在你的 TeX 发行版中找到该文件hylang.tex并将其复制到工作目录中。将其修改为

%%% This is hylang.tex (version 1.0), where language definitions
%%% actually occur. The first one should always be
%%% American English, for compatibility with plain TeX.
%%%
%%% Users can modify this file in order to define the
%%% languages they need.
%%%
%%% Every language definition should be followed by a
%%% \refinelanguage command where conventions specific to 
%%% the language are set; users should at least provide 
%%% the left and right hyphenation minima using
%%% \hyphenmins{<left>}{<right>}
%%%
%%% In the third argument one puts what has to be done
%%% when activating the language; in the fourth argument
%%% what needs to be undone.

\input unicode-letters

%%% US English must always come first
\definebaselanguage{en}{US}{hyphen} %%% <--- don't modify
\refinelanguage{en}{US}{\hyphenmins{2}{3}}{}

%%% Portuguese
\definelanguage{pt}{PT}{loadhyph-pt}
\refinelanguage{pt}{PT}{\hyphenmins{2}{3}}{}

\definedialect{pt}{BR}{pt}{PT}
\refinedialect{pt}{BR}{\hyphenmins{2}{3}}{}

%%% Add other languages if needed
%%%
%%% The arguments to \definelanguage are:
%%% #1: the language code; it is an arbitrary string, use the 
%%%     ISO two-letter language code for uniformity, or `nde' for
%%%     new orthography German
%%% #2: the nation code; use the uppercase ISO two-letter code
%%% #3: the file with hyphenation patterns
%%%
%%% The arguments to \refinelanguage and \refinedialect are:
%%% #1 and #2: a pair defined through \definelanguage or \definedialect
%%% #3: commands to be executed when entering the language
%%% #4: commands to be undone when entering a new language
%%%
% \definelanguage{xx}{YY}{xxhyph}
% \refinelanguage{xx}{YY}{<something>}{<something>}
%
% \definedialect{aa}{BB}{xx}{XX}
% \refinedialect{aa}{BB}{<something>}{<something>}

% At last the fallback, a language with no patterns
\definelanguage{zz}{ZZ}{zerohyph}
% \refinelanguage{zz}{ZZ}{}{} % no need to set conventions

%%% Aliases
\addalias\US{en}{US}
\addalias\PT{pt}{PT}
\addalias\BR{pt}{BR}
\addalias\ZZ{zz}{ZZ}
\addalias\nohyphens{zz}{ZZ}

\endinput

现在调用初始化程序

xetex -ini '*hyplain'

这将创建一个新的格式文件hyplain.fmt,您可以通过运行来测试它

xetex '&hyplain test'

哪里test.tex

\font\standard="TeX Gyre Termes/mapping=tex-text"
\standard

\parindent=0pt

\selectlanguage{pt}{PT}

\hsize=2pt

\hskip0pt
Tabelas de Hifenação

\hskip0pt
Lisboa possui inúmeras atracções turísticas. A baixa pombalina, Belém,
Chiado ou Bairro Alto, são zonas onde afluem milhares de turistas e
visitantes anualmente. Duas agências europeias têm sede em Lisboa: o
Observatório Europeu da Droga e da Toxicodependência e a Agência
Europeia de Segurança Marítima, ambas com projectos de novas sedes à
beira rio. A Comunidade dos Países de Língua Portuguesa encontra-se
igualmente sediada em Lisboa.

\bye

格式文件可以移动到合适的目录中,请查阅您的发行版手册以了解移动到何处以及如何移动。

警告:我编写了“hyplain”系统。

答案3

在 Plain TeX 中,只需设置一个未使用的语言编号,然后输入葡萄牙语的连字符模式——每个发行版中都可用的 TeX 文件,如下所示:

\language=7
\input pt8hyph.tex
\def\portugues{\language=7\relax}

模式与语言编号相关联,切换编号以更改连字规则,或创建一些定义来处理此问题。它适用于 UTF-8!

您可以获取此文件http://www.ctan.org/tex-archive/language/portuguese感谢 Pedro J. de Rezende ([电子邮件保护]) 和 J.Joao Dias Almeida ([电子邮件保护]) 进行烘烤。

相关内容