1 The Spanish language

The file spanish.dtx^{1} defines all the language definition macro’s for the Spanish^{2} language.

This file^{3} incorporates the result of discussions held in the Spanish-TEX^{4} electronic mail list.

For this language the characters ' ~ and " are made active. In table 1 an overview is given of their purpose. These active accent characters behave according

'a an accent that allows hyphenation. Valid for all vow-

els uppercase and lowercase. 'n a n with a tilde. This is included to improve com-

patibility with FTC. Works for uppercase too.

"| disable ligature at this position.

"- an explicit hyphen sign, allowing hyphenation in the

rest of the word. "" like "-, but producing no hyphen sign (for words that

should break at some sign such as “entrada/salida.” \- like the old \-, but allowing hyphenation in the rest

of the word.

"u a u with dieresis allowing hyphenation.
"a feminine ordinal as in 1^{\underline{a}}.
"o masculine ordinal as in 1^{\underline{o}}.
"< for French left double quotes (similar to <<).
"> for French right double quotes (similar to >>).
~n a n with tilde. Works for uppercase too.

Table 1: The extra definitions made by spanish.ldf

to their original definitions if not followed by one of the characters indicated in that table.

This option includes support for working with extended, 8-bit fonts, if available. Old versions of this file based this support on the existance of special macros with names as in Ferguson’s ML-TEX. This is no longer the case. Support is now based on providing an appropriate definition for the accent macros on entry to the Spanish language. This is automatically done by L^{A}TEX 2ε or NFSS2. If T1 encoding is chosen, and provided that adequate hyphenation patterns^{5} exist, it is possible to get better hyphenation for Spanish than before. The easiest way to use the new encoding with L^{A}TEX 2ε to load the package t1enc with \usepackage. This must be done before loading babel.

1The file described in this section has version number v3.4g and was last revised on 1997/01/15. The original author is Julio Sánchez, (jsanchez@gmv.es).

2Catalan used to be part of this file but is now on its own file.

3In writing this file, many ideas and actual coding solutions have been taken from a number of sources. The language definition files dutch.sty and germanb.sty are the main contributors and are not explicitly mentioned in the sequel. J. L. Braams and Bernd Raichle have given helpful advice. Another source of inspiration is the experience gained in the use of FTC, a software package written by José A. Mañas. The members of the Spanish-TEX list have helped clarify a number of issues. Other sources are explicitly acknowledged when used. If you think that you contributed something and you are not mentioned, please let me (jsanchez@gmv.es) know. I humbly apologize for any omission.

4spanish-tex@goya.eunet.es, subscription requests can be sent to the address listserv@goya.eunet.es. This list is devoted to discussions on support in TEX for Spanish.

Comments on this language option are welcome there or directly to jsanchez@gmv.es.

5One source for such patterns is the archive at ftp.eunet.es that can be accessed by anonymous FTP or electronic mail to ftpmail@goya.eunet.es. They are in the info direc-

If the combination of keyboard and TEX version that the user has is able to produce the accented characters in the T1 enconding, the user could see the accented characters in the editor, greatly improving the readability of the document source. As of today, this is not a recommended method for producing documents for distribution, although it is possible to mechanically translate the document so that the receiver can make use of it. If care is taken to define the encoding needed by the document, the results are pretty portable.

This option file will automatically detect if the T1 encoding is being used and behave appropriately. If any other encoding is being used, the accent macros will be redefined to allow hyphenation on the accented words.

The macro \LdfInit takes care of preventing that this file is loaded more than once, checking the category code of the @ sign, etc.

1 ⟨∗code⟩

 2 \LdfInit{spanish}\captionsspanish

When this file is read as an option, i.e. by the \usepackage command, spanish could be an ‘unknown’ language in which case we have to make it known. So we check for the existence of \l@spanish to see whether we have to do something here.

 3 \ifx\l@spanish\@undefined
 4 \@nopatterns{Spanish}
 5 \adddialect\l@spanish0
 6 \fi

The next step consists of defining commands to switch to (and from) the Spanish language.

\captionsspanish The macro \captionsspanish defines all strings^{6} used in the four standard documentclasses provided with L^{A}TEX.

 7 \addto\captionsspanish{%
 8 \def\prefacename{Prefacio}%
 9 \def\refname{Referencias}%
10 \def\abstractname{Resumen}%
11 \def\bibname{Bibliograf\'{\i}a}%
12 \def\chaptername{Cap\'{\i}tulo}%
13 \def\appendixname{Ap\'endice}%
14 \def\contentsname{\'Indice General}%
15 \def\listfigurename{\'Indice de Figuras}%
16 \def\listtablename{\'Indice de Tablas}%
17 \def\indexname{\'Indice de Materias}%
18 \def\figurename{Figura}%
19 \def\tablename{Tabla}%
20 \def\partname{Parte}%
21 \def\enclname{Adjunto}%

tory src/TeX/spanish. The list of Frequently Asked Questions with Answers about TEX for Spanish is kept there as well. That list is meant to be a summary of the discussions held in the Spanish-TEX mail list. Warning: It is in Spanish.

6The accent on the uppercase ‘I’ is intentional, following the recommendation of the Real Academia de la Lengua in Esbozo de una Nueva Gramática de la Lengua Española, Comisión de Gramática, Espasa-Calpe, 1973.

22 \def\ccname{Copia a}%
23 \def\headtoname{A}%
24 \def\pagename{P\'agina}%
25 \def\seename{v\'ease}%
26 \def\alsoname{v\'ease tambi\'en}%
27 \def\proofname{Demostraci\'on}%
28 }%

\datespanish The macro \datespanish redefines the command \today to produce Spanish^{7} dates.

29 \def\datespanish{%
30 \def\today{\number\day~de\space\ifcase\month\or
31 enero\or febrero\or marzo\or abril\or mayo\or junio\or
32 julio\or agosto\or septiembre\or octubre\or noviembre\or diciembre\fi
33 \space de~\number\year}}

\extrasspanish \noextrasspanish The macro \extrasspanish will perform all the extra definitions needed for the Spanish language. The macro \noextrasspanish is used to cancel the actions of \extrasspanish. For Spanish, some characters are made active or are redefined. In particular, the " character, the ' character and the ~ character receive new meanings. Therefore these characters have to be treated as ‘special’ characters.

34 \addto\extrasspanish{\languageshorthands{spanish}}
35 \initiate@active@char{"}
36 \initiate@active@char{~}
37 \addto\extrasspanish{%
38 \bbl@activate{"}%
39 \bbl@activate{~}}
40 \@ifpackagewith{babel}{activeacute}{%
41 \initiate@active@char{'}}{}
42 \@ifpackagewith{babel}{activeacute}{%
43 \addto\extrasspanish{\bbl@activate{'}}}{}
44 %\addto\noextrasspanish{
45 %  \bbl@deactivate{"}\bbl@deactivate{~}\bbl@deactivate{'}}

Apart from the active characters some other macros get a new definition. Therefore we store the current one to be able to restore them later.

46 \addto\extrasspanish{%
47 \babel@save\"%
48 \babel@save\~%
49 \def\"{\protect\@umlaut}%
50 \def\~{\protect\@tilde}}
51 \@ifpackagewith{babel}{activeacute}{%
52 \babel@save\'
53 \addto\extrasspanish{\def\'{\protect\@acute}}
54 }{}
\spanishhyphenmins Spanish hyphenation uses \lefthyphenmin and \righthyphenmin both set to 2.
55 \def\spanishhyphenmins{\tw@\tw@}

7Months are written lowercased. This has been cause of some controversy. This file follows Diccionario de Uso de la Lengua Española, María Moliner, 1990, that is in agreement with the most common practice.

\dieresis \textacute \texttilde The original definition of \" is stored as \dieresis, because the we do not know what is its definition, since it depends on the encoding we are using or on special macros that the user might have loaded. The expansion of the macro might use the TEX \accent primitive using some particular accent that the font provides or might check if a combined accent exists in the font. These two cases happen with respectively OT1 and T1 encodings. For this reason we save the definition of \" and use that in the definition of other macros. We do likewise for \' and \~. The present coding of this option file is incorrect in that it can break when the encoding changes. We do not use \acute or \tilde as the macro names because they are already defined as \mathaccent.

56 \let\dieresis\"
57 \let\texttilde\~
58 \@ifpackagewith{babel}{activeacute}{\let\textacute\'}{}

\@umlaut \@acute \@tilde We check the encoding and if not using T1, we make the accents expand but enabling hyphenation beyond the accent. If this is the case, not all break positions will be found in words that contain accents, but this is a limitation in TEX. An unsolved problem here is that the encoding can change at any time. The definitions below are made in such a way that a change between two 256-char encodings are supported, but changes between a 128-char and a 256-char encoding are not properly supported. We check if T1 is in use. If not, we will give a warning and proceed redefining the accent macros so that TEX at least finds the breaks that are not too close to the accent. The warning will only be printed to the log file.

59 \ifx\DeclareFontShape\@undefined
60 \wlog{Warning: You are using an old LaTeX}
61 \wlog{Some word breaks will not be found.}
62 \def\@umlaut#1{\allowhyphens\dieresis{#1}\allowhyphens}
63 \def\@tilde#1{\allowhyphens\texttilde{#1}\allowhyphens}
64 \@ifpackagewith{babel}{activeacute}{%
65  \def\@acute#1{\allowhyphens\textacute{#1}\allowhyphens}}{}
66 \else
67 \edef\next{T1}
68 \ifx\f@encoding\next
69  \let\@umlaut\dieresis
70  \let\@tilde\texttilde
71  \@ifpackagewith{babel}{activeacute}{%
72  \let\@acute\textacute}{}
73 \else
74  \wlog{Warning: You are using encoding \f@encoding\space
75  instead of T1.}
76  \wlog{Some word breaks will not be found.}
77  \def\@umlaut#1{\allowhyphens\dieresis{#1}\allowhyphens}
78  \def\@tilde#1{\allowhyphens\texttilde{#1}\allowhyphens}
79  \@ifpackagewith{babel}{activeacute}{%
80  \def\@acute#1{\allowhyphens\textacute{#1}\allowhyphens}}{}
81 \fi
82 \fi

Now we can define our shorthands: the umlauts,

83 \declare@shorthand{spanish}{"u}{\@umlaut u}
84 \declare@shorthand{spanish}{"U}{\@umlaut U}

french quotes,

 85 \declare@shorthand{spanish}{"<}{%
 86 \textormath{\guillemotleft{}}{\mbox{\guillemotleft}}}
 87 \declare@shorthand{spanish}{">}{%
 88 \textormath{\guillemotright{}}{\mbox{\guillemotright}}}

ordinals^{8},

 89 \declare@shorthand{spanish}{"o}{%
 90 \leavevmode\raise1ex\hbox{\underbar{\scriptsize o}}}
 91 \declare@shorthand{spanish}{"a}{%
 92 \leavevmode\raise1ex\hbox{\underbar{\scriptsize a}}}

acute accents,

 93 \@ifpackagewith{babel}{activeacute}{%
 94 \declare@shorthand{spanish}{'a}{\textormath{\@acute a}{^{\prime} a}}
 95 \declare@shorthand{spanish}{'e}{\textormath{\@acute e}{^{\prime} e}}
 96 \declare@shorthand{spanish}{'i}{\textormath{\@acute\i{}}{^{\prime}i}}
 97 \declare@shorthand{spanish}{'o}{\textormath{\@acute o}{^{\prime} o}}
 98 \declare@shorthand{spanish}{'u}{\textormath{\@acute u}{^{\prime} u}}
 99 \declare@shorthand{spanish}{'A}{\textormath{\@acute A}{^{\prime} A}}
100 \declare@shorthand{spanish}{'E}{\textormath{\@acute E}{^{\prime} E}}
101 \declare@shorthand{spanish}{'I}{\textormath{\@acute I}{^{\prime} I}}
102 \declare@shorthand{spanish}{'O}{\textormath{\@acute O}{^{\prime} O}}
103 \declare@shorthand{spanish}{'U}{\textormath{\@acute U}{^{\prime} U}}

the acute accent,

104 \declare@shorthand{spanish}{''}{%
105  \textormath{\textquotedblright}{\sp\bgroup\prim@s'}}

tildes,

106 \declare@shorthand{spanish}{'n}{\textormath{\~n}{^{\prime} n}}
107 \declare@shorthand{spanish}{'N}{\textormath{\~N}{^{\prime} N}}
108 }{}
109 \declare@shorthand{spanish}{~n}{\textormath{\~n}{\@tilde n}}
110 \declare@shorthand{spanish}{~N}{\textormath{\~N}{\@tilde N}}

and some additional commands:

111 \declare@shorthand{spanish}{"-}{\allowhyphens\-\allowhyphens}
112 \declare@shorthand{spanish}{"|}{%
113 \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
114  \allowhyphens}{}}
115 \declare@shorthand{spanish}{""}{\hskip\z@skip}

The macro \ldf@finish takes care of looking for a configuration file, setting the main language to be switched on at \begin{document} and resetting the category code of @ to its original value.

116 \ldf@finish{spanish}

117 ⟨/code⟩

8The code for the ordinals was taken from the answer provided by Raymond Chen (raymond@math.berkeley.edu) to a question by Joseph Gil (yogi@cs.ubc.ca) in comp.text.tex.