diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/thailatex/babel/thai.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/thailatex/babel/thai.dtx | 257 |
1 files changed, 148 insertions, 109 deletions
diff --git a/Master/texmf-dist/source/latex/thailatex/babel/thai.dtx b/Master/texmf-dist/source/latex/thailatex/babel/thai.dtx index 131b3ab8a71..68f326e6852 100644 --- a/Master/texmf-dist/source/latex/thailatex/babel/thai.dtx +++ b/Master/texmf-dist/source/latex/thailatex/babel/thai.dtx @@ -29,7 +29,7 @@ %<code>\ProvidesLanguage{thai} %\fi %\ProvidesFile{thai.dtx} - [2011/03/17 v1.3 Thai support from the babel system] + [2011/12/19 v1.4c Thai support from the babel system] %\iffalse %% File `thai.dtx' %% Thai Language Definition File @@ -129,67 +129,108 @@ % Add \cs{\backslash{}textpali} macro for typesetting Pali text with % descender-less Yo Ying and Tho Than. Update translation for % \cs{\backslash{}refname}} -% -% \section{The Thai language} -% -% The file \file{\filename}\footnote{The file described in this section has -% version number \fileversion\ and was last revised on \filedate. Contributions -% were made by Theppitak Karoonboonyanan (\texttt{thep@linux.thai.net}).} -% defines language-specific macros for Thai language. -% -% Thai documents to be supported by this language definition can be encoded -% in TIS-620 (or ISO/IEC 8859-11) or UTF-8 (with the aids of \texttt{inputenc} -% package). -% -% Thai is written continuously without word delimitors. The word boundary -% analysis is considered too complicated for rule-based approaches. -% Most good quality word analysis tools available employ special matching -% algorithms against pre-defined dictionaries. Some even use contextual -% analysis for ambiguous cases based on statistics. Therefore, no good -% hyphenation pattern is found to be comparable with those tools yet. -% -% \DescribeMacro{\wbr} -% What the Thai language definition provides here for the word boundary -% problem is the |\wbr| command for separating words. It occupies no -% space but aids the \TeX\ typesetter in wrapping lines at proper positions, -% meanwhile leaves some room for distributing little spaces between words -% in case of narrow columns. -% -% Some preprocessing tools that analyze word boundaries and insert the |\wbr| -% commands are available, for example -% \begin{itemize} -% \item \emph{cttex} by Vuthichai Ampornaramveth -% \item \emph{swath} by Phaisarn Charoenpornsawat, now maintained by Thai -% Linux Working Group, downloadable from:\\ -% \texttt{ftp://linux.thai.net/pub/thailinux/software/swath} -% \end{itemize} -% -% Some certain Thai documents use Thai digits instead of Arabic. -% And Thai alphabetic numbering is also commonly used for appendices. -% This file provides a number of numbering styles that can apply -% to \LaTeX\ |\pagenumbering| command: -% -% \begin{itemize} -% \item |\thainum| for plain Thai digits -% \item |\thaibracenum| for Thai digits in parentheses -% \item |\thaialph| for Thai alphabetic numbering, using a reduced set -% (with three alphabets skipped: Kho Khuat, Kho Khon and Kho Rakhang) -% \item |\thaiAlph| for Thai alphabetic numbering, using the full set -% (with full alphabet set, plus two semi-vowels, Ru and Lu, in the -% order defined in Thai official dictionary) -% \end{itemize} -% -% \DescribeEnv{thainumber} -% The above numbering styles can be automatically chosen with the -% \Lopt{thainumber} option. When supplying this option to the \babel{} -% package, Thai numberings will be applied to pages, sections, enumerations, -% dates, etc. +% \changes{thai-1.4}{2011/10/18}{Theppitak Karoonboonyanan: +% Remove font-specific macros} +% \changes{thai-1.4a}{2011/11/23}{Theppitak Karoonboonyanan: +% Revise documentation} +% \changes{thai-1.4b}{2011/12/16}{Theppitak Karoonboonyanan: +% Remove extra space in \cs{\backslash{}wbr}. Word spacing is considered +% suboptimal.} +% \changes{thai-1.4c}{2011/12/19}{Theppitak Karoonboonyanan: +% Revise documentation} +% \changes{thai-1.4d}{2012/02/10}{Theppitak Karoonboonyanan: +% Revise documentation. Add documentation for Thai line stretching.} +% +% \section{The Thai language} +% +% The file \file{\filename}\footnote{The file described in this section has +% version number \fileversion\ and was last revised on \filedate. The +% original author was Surapant Meknavin, and it was composed into +% \file{\filename} and maintained by Theppitak Karoonboonyanan +% (\texttt{thep@linux.thai.net}).} +% defines language-specific macros for Thai language. +% +% \subsection{Input encoding} +% +% Thai documents supported by this language definition can be encoded in +% either TIS-620 (ISO/IEC 8859-11) or UTF-8 with the aids of the +% \texttt{inputenc} package. +% +% \DescribeMacro{\thaitext} +% \DescribeMacro{\latintext} +% The commands |\thaitext| and |\latintext| can be used to switch to Thai +% or Latin fonts. These are declarations. +% +% \DescribeMacro{\textthai} +% \DescribeMacro{\textlatin} +% The commands |\textthai| and |\textlatin| both take one text argument +% which is then typeset using the requested language settings. +% +% \DescribeMacro{\textpali} +% The command |\textpali| takes one text argument which is then typeset +% using Thai font, with special shapes for certain characters, such as +% descender-less Yo Ying and Tho Than, as required by usual Pali-Sanskrit +% transliteration. +% +% \subsection{Word breaks} +% +% Thai is written continuously without word delimitors. The word boundary +% analysis is considered too complicated for rule-based approaches. +% Most available good-quality word analysis tools employ special matching +% algorithms against pre-defined dictionaries. Some even use +% statistics-based contextual analysis to resolve ambiguities. Therefore, +% no good hyphenation pattern is found to be comparable with those tools +% yet. +% +% \DescribeMacro{\wbr} +% What provided here for the word boundary problem is the |\wbr| command +% for separating words. It delimits words without taking physical space, +% so that the \TeX\ typesetter still wraps lines at word boundary like +% when it typesets English text. +% +% Therefore, one can preprocess their Thai document using Thai word analysis +% tools which automatically insert the |\wbr| commands between words, such +% as: +% \begin{itemize} +% \item \emph{cttex} by Vuthichai Ampornaramveth +% \item \emph{swath} by Phaisarn Charoenpornsawat, now maintained by Thai +% Linux Working Group, which can be downloaded from:\\ +% \texttt{ftp://linux.thai.net/pub/thailinux/software/swath} +% +% To compile \emph{swath}, you need \emph{libdatrie} as the +% dependency, which is provided under the \emph{libthai} project:\\ +% \texttt{ftp://linux.thai.net/pub/thailinux/software/libthai} +% \end{itemize} +% +% \subsection{Thai numbering} +% \label{thai-numbering} +% +% Some certain Thai documents use Thai digits instead of Arabic. +% And Thai alphabetic numbering is also commonly used for appendices. +% This file provides a number of numbering styles that can be applied +% to \LaTeX\ |\pagenumbering| command: +% +% \begin{itemize} +% \item |\thainum| for plain Thai digits +% \item |\thaibracenum| for Thai digits in parentheses +% \item |\thaialph| for Thai alphabetic numbering, using a reduced set +% (with three alphabets skipped: Kho Khuat, Kho Khon and Kho Rakhang) +% \item |\thaiAlph| for Thai alphabetic numbering, using the full set +% (with full alphabet set, plus two semi-vowels, Ru and Lu, in the +% order defined in Thai official dictionary) +% \end{itemize} +% +% \DescribeEnv{thainumber} +% The above numbering styles can be automatically chosen using the +% \Lopt{thainumber} option. When this option is supplied to the \babel{} +% package, Thai numberings will be applied to pages, sections, +% enumerations, dates, etc. % % \StopEventually{} % % \subsection{Thai language definition} % -% The macro |\LdfInit| takes care of preventing that this file is +% The macro |\LdfInit| takes care of preventing file from being % loaded more than once, checking the category code of the % \texttt{@} sign, etc. % \begin{macrocode} @@ -198,8 +239,8 @@ % \end{macrocode} % % When this file is read as an option, i.e. by the |\usepackage{babel}| -% command, \texttt{thai} will be an `unknown' language in which -% case we have to make it known. So we check for the existence of +% command, \texttt{thai} will be an `unknown' language, in which +% case we have to make it known. So, we check for the existence of % |\l@thai| to see whether we have to do something here. % % \begin{macrocode} @@ -218,55 +259,37 @@ % the \file{lthenc.def} file. So, we require it. % % \begin{macrocode} -\InputIfFileExists{lthenc.def}{% - \message{Loading the definitions for the Thai font encoding}}{% - \errhelp{I can't find the lthenc.def file for the Thai fonts}% - \errmessage{Since I do not know what the LTH encoding means^^J - I can't typeset Thai.^^J - I stop here, while you get a suitable lthenc.def file}\@@end - } -% \end{macrocode} -% -% Then, we define default fonts for the document. \texttt{norasi} and -% \texttt{garuda} are Serif and San Serif fonts from the National Fonts -% Project, initiated by NECTEC. \texttt{ttypist} is a typewriter font -% created by Theppitak Karoonboonyanan from Thai Linux Working Group. -% All fonts are available in free license. -% -% \begin{macrocode} -\def\thairmdefault{norasi} -\def\thaisfdefault{garuda} -\def\thaittdefault{ttypist} -\def\englishrmdefault{cmr} -\def\englishsfdefault{cmss} -\def\englishttdefault{cmtt} +\InputIfFileExists{lthenc.def}% + {\message{Loading the definitions for the Thai font encoding}}% + {% + \errhelp{I can't find the lthenc.def file for the Thai fonts}% + \errmessage{Since I do not know what the LTH encoding means^^J + I can't typeset Thai.^^J + I stop here, while you get a suitable lthenc.def file}\@@end + } % \end{macrocode} % -% The next step consists of defining commands to switch to the -% Thai language. The reason for this is that a user might want -% to switch back and forth between languages. +% The next step consists of defining commands to switch to the Thai +% language, for users to switch back and forth between languages. % % \begin{macro}{\thaitext} % We define |\thaitext| as a declarative switch to Thai font encoding. % \begin{macrocode} \DeclareRobustCommand{\thaitext}{% - \fontencoding{LTH}\fontfamily{\thairmdefault}\selectfont% - \def\rmdefault{\thairmdefault}% - \def\sfdefault{\thaisfdefault}% - \def\ttdefault{\thaittdefault}% + \fontencoding{LTH}\selectfont% \def\encodingdefault{LTH}} % \end{macrocode} % \end{macro} % % \begin{macro}{\textthai} -% This command takes an argument which is then typeset using Thai font +% This command takes one text argument which is then typeset using Thai font % encoding. % \begin{macrocode} \DeclareRobustCommand{\textthai}[1]{{\thaitext #1}} % \end{macrocode} % \end{macro} % -% \subsubsection{Pali-Sanskrit Characters} +% \subsubsection{Pali-Sanskrit Transliteration} % % Thai script can also be used for writing Pali and Sanskrit. Additional % conventions are applied when doing so: (a) Yo Ying and Tho Than must be @@ -280,7 +303,7 @@ % provision in the fonts. % % What is left here is (a). Yo Ying and Tho Than must be converted to -% their descender-less vairations. The |\textpali| macro is defined +% their descender-less variants. The |\textpali| macro is defined % for this purpose. Note that |\wbr| commands which are normally inserted % by automatic tools are ignored here, as most of such tools are not % designed for Pali/Sanskrit. Besides, Pali/Sanskrit is already space @@ -308,7 +331,7 @@ % % \begin{macro}{\thaihyphenmins} % This macro is used to store the correct values of the hyphenation -% parameters |\lefthyphenmin| and |\righthyphenmin|. They are set to 11. +% parameters |\lefthyphenmin| and |\righthyphenmin|. They are set to 11. % \changes{thai-1.1}{2006/07/02}{Theppitak Karoonboonyanan: % Now use \cs{providehyphenmins} to provide a default value} % \begin{macrocode} @@ -446,14 +469,26 @@ % \TeX typesetter can wrap Thai lines at proper positions. % % \begin{macrocode} -\def\wbr{\hskip0pt plus0.6pt\relax} +\def\wbr{\hskip0pt\relax} +% \end{macrocode} +% +% \subsection{Line spacing} +% +% Due to multi-level combining character stacking, Thai text lines +% can occupy more vertical space than English. To prevent overlapping, +% \TeX{} allocates more height for lines with combining characters +% but not for those without. This can cause irregular line spacing. +% To avoid this problem, we need to stretch the line spacing. +% +% \begin{macrocode} \renewcommand{\baselinestretch}{1.2} % \end{macrocode} % % \subsection{Thai numbering support} % -% This section provides Thai numbering styles as described at the beginning -% of this document: |\thainum|, |\thaibracenum|, |\thaialph| and |\thaiAlph|. +% This section provides Thai numbering styles as described in +% \S\ref{thai-numbering}: |\thainum|, |\thaibracenum|, |\thaialph| and +% |\thaiAlph|. % % First, we define a macro for translating decimal digits into Thai digits. % @@ -473,18 +508,18 @@ % \end{macro} % % \begin{macro}{\thainum} -% The |\thainum| macro is to be used as a numbering style in \LaTeX\ -% |\pagenumbering| command. +% The |\thainum| macro is to be used as a numbering style in \LaTeX\ +% |\pagenumbering| command. % -% It takes a counter name and converts its value into Thai digits. -% In details, it prepends the counter name with `|c@|' to access the counter -% value, then calls |\@thainum| to convert it into Thai digits. +% It takes a counter name and converts its value into Thai digits. +% In details, it prepends the counter name with `|c@|' to access the counter +% value, then calls |\@thainum| to convert it into Thai digits. % -% The |\@thainum| macro converts a number into Thai digits. It expands the -% argument into a number, terminates it with `|@|', and calls -% |\thaitranslate| to convert it into Thai digits. +% The |\@thainum| macro converts a number into Thai digits. It expands the +% argument into a number, terminates it with `|@|', and calls +% |\thaitranslate| to convert it into Thai digits. % -% \begin{macrocode} +% \begin{macrocode} \def\@thainum#1{\expandafter\thaitranslate\number#1@} \def\thainum#1{\expandafter\@thainum\csname c@#1\endcsname} % \end{macrocode} @@ -555,7 +590,7 @@ % % Not all Thai documents use Thai digits. So, we support this as an % option. If \Lopt{thainumber} option is supplied in the |\usepackage| -% command, all numbering will use Thai digits. +% command, Thai digits will be used in all numberings. % % \begin{macrocode} \DeclareOption{thainumber}{ @@ -619,9 +654,11 @@ \def\@oddhead{\reset@font\hfil\thepage\hfil}\let\@oddfoot\@empty \let\@evenhead\@oddhead\let\@evenfoot\@empty} \let\@ltxfrontmatter\frontmatter - \renewcommand\frontmatter{\@ltxfrontmatter\pagestyle{headnum}\pagenumbering{thaibracenum}} + \renewcommand\frontmatter% + {\@ltxfrontmatter\pagestyle{headnum}\pagenumbering{thaibracenum}} \let\@ltxmainmatter\mainmatter - \renewcommand\mainmatter{\@ltxmainmatter\pagestyle{headings}\pagenumbering{thainum}} + \renewcommand\mainmatter% + {\@ltxmainmatter\pagestyle{headings}\pagenumbering{thainum}} }{} % \end{macrocode} % @@ -629,7 +666,9 @@ % % \begin{macrocode} \def\datethai{% - \def\today{\@thainum\day \space \th@month\space \thaiPhoPhan.\thaiSoSala.~\@thainum\th@year}} + \def\today{\@thainum\day\space \th@month\space % + \thaiPhoPhan.\thaiSoSala.~\@thainum\th@year} +} % \end{macrocode} % % And finish declaration of \Lopt{thainumber} option @@ -664,7 +703,7 @@ }{} % \end{macrocode} % -% \subsection{Miscelleneous} +% \subsection{Miscellaneous} % % Initialize character codes for Thai % |