1 The Swedish language

The file swedish.dtx^{1} defines all the language-specific macros for the Swedish language.

For this language the character " is made active. In table 1 an overview is given of its purpose. The vertical placement of the ”umlaut” in some letters can be controlled this way.

"a   \"a, also implemented for A, o and O.
"w gives å, also works for uppercase letters.

"ff for ff to be hyphenated as ff-f, this is also implemented for b, d, f, g, l, m, n, p, r, s, and t.

"| disable ligature at this position.

"- an explicit hyphen sign, allowing hyphenation in the

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

words with hyphen, e.g. x-""y).

"~ for a compound word mark without a breakpoint.

"= for a compound word mark with a breakpoint, allowing hyphenation in the composing words.

Table 1: The extra definitions made by swedish.sty

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{swedish}\captionsswedish

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

 3 \ifx\l@swedish\@undefined
 4  \@nopatterns{Swedish}
 5  \adddialect\l@swedish0\fi

The next step consists of defining commands to switch to the Swedish language. The reason for this is that a user might want to switch back and forth between languages.

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

 6 \addto\captionsswedish{%
 7 \def\prefacename{F\"orord}%
 8 \def\refname{Referenser}%
 9 \def\abstractname{Sammanfattning}%
10 \def\bibname{Litteraturf\"orteckning}%
11 \def\chaptername{Kapitel}%

1The file described in this section has version number v2.1 and was last revised on 1996/12/23. Contributions were made by Sten Hellman (HELLMAN@CERNVM.CERN.CH) and Erik Öshols (erik@ine.kfk.de).

12 \def\appendixname{Bilaga}%
13 \def\contentsname{Inneh\csname aa\endcsname ll}%
14 \def\listfigurename{Figurer}%
15 \def\listtablename{Tabeller}%
16 \def\indexname{Sakregister}%
17 \def\figurename{Figur}%
18 \def\tablename{Tabell}%
19 \def\partname{Del}%
20 \def\enclname{Bil}%
21 \def\ccname{Kopia f\"or k\"annedom}%
22 \def\headtoname{Till}% in letter
23 \def\pagename{Sida}%
24 \def\seename{se}%
25 \def\alsoname{se \"aven}%
26 \def\proofname{Bevis}%
27 }%

\dateswedish The macro \dateswedish redefines the command \today to produce Swedish dates.

28 \def\dateswedish{%
29 \def\today{%
30  \number\day~\ifcase\month\or
31  januari\or februari\or mars\or april\or maj\or juni\or
32  juli\or augusti\or september\or oktober\or november\or
33  december\fi
34  \space\number\year}}

\swedishhyphenmins The swedish hyphenation patterns can be used with \lefthyphenmin set to 2 and

\righthyphenmin set to 2.
35 \def\swedishhyphenmins{\tw@\tw@}

\extrasswedish \noextrasswedish The macro \extrasswedish performs all the extra definitions needed for the Swedish language. The macro \noextrasswedish is used to cancel the actions

of \extrasswedish.

For Swedish texts \frenchspacing should be in effect. We make sure this is the case and reset it if necessary.

36 \addto\extrasswedish{\bbl@frenchspacing}
37 \addto\noextrasswedish{\bbl@nonfrenchspacing}

For Swedish the " character is made active. This is done once, later on its definition may vary.

38 \initiate@active@char{"}
39 \addto\extrasswedish{\languageshorthands{swedish}}
40 \addto\extrasswedish{\bbl@activate{"}}
41 %\addto\noextrasswedish{\bbl@deactivate{"}}

The “umlaut” accent macro \" is changed to lower the umlaut dots. The redefinition is done with the help of \umlautlow.

42 \addto\extrasswedish{\babel@save\"\umlautlow}
43 \addto\noextrasswedish{\umlauthigh}

The code above is necessary because we need an extra active character. This character is then used as indicated in table 1.

To be able to define the function of ", we first define a couple of ‘support’ macros.

\dq We save the original double quote character in \dq to keep it available, the math accent \" can now be typed as ".

44 \begingroup \catcode`\"12
45 \def\x{\endgroup
46 \def\@SS{\mathchar"7019 }
47 \def\dq{"}}
48 \x

Now we can define the doublequote macros: the umlauts and å,

49 \declare@shorthand{swedish}{"w}{\textormath{{\aa}}{\ddot w}}
50 \declare@shorthand{swedish}{"a}{\textormath{\"{a}}{\ddot a}}
51 \declare@shorthand{swedish}{"o}{\textormath{\"{o}}{\ddot o}}
52 \declare@shorthand{swedish}{"W}{\textormath{{\AA}}{\ddot W}}
53 \declare@shorthand{swedish}{"A}{\textormath{\"{A}}{\ddot A}}
54 \declare@shorthand{swedish}{"O}{\textormath{\"{O}}{\ddot O}}

discretionary commands

55 \declare@shorthand{swedish}{"b}{\textormath{\bbl@disc b{bb}}{b}}
56 \declare@shorthand{swedish}{"B}{\textormath{\bbl@disc B{BB}}{B}}
57 \declare@shorthand{swedish}{"d}{\textormath{\bbl@disc d{dd}}{d}}
58 \declare@shorthand{swedish}{"D}{\textormath{\bbl@disc D{DD}}{D}}
59 \declare@shorthand{swedish}{"f}{\textormath{\bbl@disc f{ff}}{f}}
60 \declare@shorthand{swedish}{"F}{\textormath{\bbl@disc F{FF}}{F}}
61 \declare@shorthand{swedish}{"g}{\textormath{\bbl@disc g{gg}}{g}}
62 \declare@shorthand{swedish}{"G}{\textormath{\bbl@disc G{GG}}{G}}
63 \declare@shorthand{swedish}{"l}{\textormath{\bbl@disc l{ll}}{l}}
64 \declare@shorthand{swedish}{"L}{\textormath{\bbl@disc L{LL}}{L}}
65 \declare@shorthand{swedish}{"m}{\textormath{\bbl@disc m{mm}}{m}}
66 \declare@shorthand{swedish}{"M}{\textormath{\bbl@disc M{MM}}{M}}
67 \declare@shorthand{swedish}{"n}{\textormath{\bbl@disc n{nn}}{n}}
68 \declare@shorthand{swedish}{"N}{\textormath{\bbl@disc N{NN}}{N}}
69 \declare@shorthand{swedish}{"p}{\textormath{\bbl@disc p{pp}}{p}}
70 \declare@shorthand{swedish}{"P}{\textormath{\bbl@disc P{PP}}{P}}
71 \declare@shorthand{swedish}{"r}{\textormath{\bbl@disc r{rr}}{r}}
72 \declare@shorthand{swedish}{"R}{\textormath{\bbl@disc R{RR}}{R}}
73 \declare@shorthand{swedish}{"s}{\textormath{\bbl@disc s{ss}}{s}}
74 \declare@shorthand{swedish}{"S}{\textormath{\bbl@disc S{SS}}{S}}
75 \declare@shorthand{swedish}{"t}{\textormath{\bbl@disc t{tt}}{t}}
76 \declare@shorthand{swedish}{"T}{\textormath{\bbl@disc T{TT}}{T}}

and some additional commands:

77 \declare@shorthand{swedish}{"-}{\penalty\@M\-\allowhyphens}
78 \declare@shorthand{swedish}{"|}{%
79 \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
80  \allowhyphens}{}}
81 \declare@shorthand{swedish}{""}{\hskip\z@skip}
82 \declare@shorthand{swedish}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
83 \declare@shorthand{swedish}{"=}{\penalty\@M-\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.

84 \ldf@finish{swedish}

85 ⟨/code⟩