<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% \iffalse meta-comment
%
% Copyright 2013 Georgi N. Boshnakov
% Copyright 1989-2008 Johannes L. Braams and any individual authors
% listed elsewhere in this file.  All rights reserved.
%
% This file is part of the Babel system.
% --------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is Georgi N. Boshnakov
%
% \fi
% \CheckSum{1881}
%
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%&lt;*dtx&gt;
\ProvidesFile{bulgarian.dtx}
%&lt;/dtx&gt;
%&lt;code&gt;\ProvidesLanguage{bulgarian}
          [2013/10/14 v1.2g Bulgarian support from the babel system]
%
%% File `bulgarian.dtx'
%% Babel package for LaTeX version 2e
%% Copyright (C) 1989-2008
%%               by Johannes Braams,TeXniek
%
%% Bulgarian Language Definition File
%% Copyright (C) 1995-2008
%%               by Georgi N. Boshnakov &lt;georgi.boshnakov at umist.ac.uk&gt;
%%                  Johannes Braams, TeXniek
%
%% Original version adapted from russianb.dtx (August-1998 version)
%%               by Georgi N. Boshnakov &lt;georgi.boshnakov at umist.ac.uk&gt;
%
%% Copyright (C) 2013
%%               by Georgi N. Boshnakov
%
%% Please report errors to: Georgi N. Boshnakov
%%               georgi.boshnakov at manchester dot ac dot uk
%
%&lt;*filedriver&gt;
\documentclass{ltxdoc}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi&gt;0
    \usepackage{fontspec}
    \defaultfontfeatures{Ligatures={TeX}}
    \setmainfont{CMU Serif}
    \setsansfont{CMU Sans Serif}
    \setmonofont{CMU Typewriter Text}
\else
    \usepackage[T1,T2A]{fontenc}
    \usepackage[utf8]{inputenc}
\fi
\usepackage[main=bulgarian,english]{babel}
%
\newcommand\TeXhax{\TeX hax}
\newcommand\babel{\textsf{babel}}
\newcommand\langvar{$\langle\it lang \rangle$}
\newcommand\note[1]{}
\newcommand\Lopt[1]{\textsf{#1}}
\newcommand\file[1]{\texttt{#1}}
\newcommand\pkg[1]{\texttt{#1}}
%\AtBeginDocument{\OnlyDescription} % uncomment to print only the user's guide
% Indexes
\AtBeginDocument{\CodelineIndex}
%\PageIndex           % Index code by page number
\AtBeginDocument{\EnableCrossrefs}
%\DisableCrossrefs   % Say \DisableCrossrefs if index is ready
\AtBeginDocument{\RecordChanges}   % Gather update information
% print the indexes
\AtEndDocument{\PrintIndex}
\AtEndDocument{\PrintChanges}
% To process the indexes do (see the documentation of 'doc'):
%    makeindex -s gind.ist bulgarian.idx
%    makeindex -s gglo.ist -o bulgarian.gls bulgarian.glo
\DoNotIndex{%
    \cyra,\cyrb,\cyrv,\cyrg,\cyrd,\cyre,\cyrzh,\cyrz,\cyri,\cyrishrt%
    ,\cyrk,\cyrl,\cyrm,\cyrn,\cyro,\cyrp,\cyrr,\cyrs,\cyrt,\cyru,\cyrf%
    ,\cyrh,\cyrc,\cyrch,\cyrsh,\cyrshch,\cyrhrdsn,\cyrsftsn,\cyryu,\cyrya%
    ,\cyrery,\cyrerev,\cyrii,\cyryar
    ,\CYRA,\CYRB,\CYRV,\CYRG,\CYRD,\CYRE,\CYRZH,\CYRZ,\CYRI,\CYRISHRT%
    ,\CYRK,\CYRL,\CYRM,\CYRN,\CYRO,\CYRP,\CYRR,\CYRS,\CYRT,\CYRU,\CYRF%
    ,\CYRH,\CYRC,\CYRCH,\CYRSH,\CYRSHCH,\CYRHRDSN,\CYRSFTSN,\CYRYU,\CYRYA%
    ,\CYRERY,\CYREREV,\CYRII,\CYRYAR
    ,\def,\edef,\else,\fi,\if
}


\begin{document}
\GetFileInfo{bulgarian.dtx}

\title{The Bulgarian language definition file \\
 for the \babel\ system\footnote{The file described in this
section has version number \fileversion\ and was last revised on
\filedate.} \\[0.5em]
 \large Version \fileversion}

\author{Georgi N. Boshnakov\footnote{ 
The original, non-babel, version (bulgaria.sty) was developed by Georgi
N. Boshnakov in 1994--1996. It was later adapted for \babel{} by Georgi
N. Boshnakov and Johannes Braams using as a template the August-1998
version of \file{russianb.dtx} and heavily borrowing code from there. I
am also grateful to Vladimir Volovich for his helpful and timely
advice. 
For versions 1.1-1.2 of the Bulgarian style, significant additions and
modification to the code were made and the user manual was almost
completely rewritten.}
%
%\footnote{Current maintainer}
%and 
%Johannes Braams\footnote{Maintainer from 1998-2008}
%
}

\date{\filedate}

\maketitle

{\small\tableofcontents}


\section{Introduction}

This file provides Bulgarian language support for the \babel{} system.

This version of the Bulgarian style is the first public revision afer the release of version
3.9 of \babel{} but it should be compatible with previous versions of \babel. More
specifically, documents that compile successfully with the last version of \babel{} before
3.9 should continue to compile. 
% The main purpose of this release of the Bulgarian style is to establish if this statement
% is true.
The documentation is draft, suggestions and meaningful examples are welcome.

This version corrects some bugs and introduces support for Luatex and
XeTeX. The documentation has been rewritten (to a large extent).
A few other small changes have been made as well, see the index
of changes at the end of this document for details.

Please report  any bugs to the current maintainer (Georgi N. Boshnakov). 



% For The Bulgarian language the character |"| is made active. % | to make Emacs
                                                    % fontification happy

\section{User guide}


\subsection{Settings things up}
\label{sec:settings-things-up}

The Bulgarian style described in this document is used by supplying
|bulgarian| as one of the language options to \babel{} when loading it.
If more than one language is requested, the last one designates the main
language of the document and it will be active after |begin{document}|.  
For example, the command
\begin{verbatim}
  \usepackage[english,bulgarian]{babel}
\end{verbatim}
loads \babel{} with the English and Bulgarian styles and sets Bulgarian
as the main language. 

For recent versions of \babel{} the main language can be specified also
with the help of  the option |main|:
\begin{verbatim}
  \usepackage[main=bulgarian,english]{babel}
\end{verbatim}


For typesetting with the classic engines, \LaTeX{} and pdf\LaTeX{}, it
is also necessary to specify the encoding of the source file (input
encoding) and the font encoding.  For the unicode based engines,
LuaLaTeX and Xetex, this is not necessary but but one needs to specify
fonts.  These issues are briefly considered below.


\subsubsection{Settings for LaTeX and pdfLaTeX }
\label{sec:latex}

Here is a template to be inserted towards the beginning of the main
\LaTeX{} file, after the |documentclass| command:
\begin{verbatim}
  \usepackage[T1,T2A]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage[bulgarian]{babel}
\end{verbatim}
This assumes UTF-8 encoded file. If this is not the case, |utf8| should
be replaced by the actual encoding, most likely |cp1251|:
\begin{verbatim}
  \usepackage[T1,T2A]{fontenc}
  \usepackage[cp1251]{inputenc}
  \usepackage[bulgarian]{babel}
\end{verbatim}
If the input encoding is not specified (i.e. the corresponding line
above is missing), a warning is issued in the log file and \LaTeX{}
still tries to typeset the document. It may be sucessful but it is
better to specify the encoding explicitly.

The options for |fontenc| may look misterious but it is safe to ignore
the details and simply insert the above command as is. Basically, |T1|
and  |T2A| can be considered standard \TeX{} encodings for the Latin
and Cyrillic letters, respectively. |T2A| contains Latin letters, as
well, so |\usepackage[T2A]{fontenc}| is often good enough.

Actually, the encodings have some fallback defaults and a document may
compile successfully even if one or both of |fontenc| and |inputenc| are
omitted. However, it is a good idea to supply explicit |inputenc| in any
case.


The support provided by \texttt{inputenc} package for unicode symbols is not
complete. If \LaTeX{} complains about undefined or unknown unicode
symbols, there is the alternative to use package |ucs| and specify
|utf8x| for inputenc, as in:
\begin{verbatim}
  \usepackage{ucs}
  \usepackage[utf8x]{inputenc}
\end{verbatim}
In many cases this simply works. Otherwise see the documentation of
package |ucs| for further details.


\subsubsection{Settings for Lualatex}
\label{sec:lualatex}

Lualatex requires that the source file is in UTF-8 encoding. It requires
also the specification of fonts. This is done by loading package
|fontspec| (attention: not |fontenc|) and issuing a sequence of font
setting commands.  The following can be used to arrange for the unicode
versions of the traditional Computer Roman fonts to be used in the
document:
\begin{verbatim}
  \usepackage{fontspec}
  \setmainfont{CMU Serif}
  \setsansfont{CMU Sans Serif}
  \setmonofont{CMU Typewriter Text}
  \usepackage[english,bulgarian]{babel}
\end{verbatim}
Any system fonts can be used instead. For example, the main font command
above could be replaced by the following:
\begin{verbatim}
  \setmainfont[Ligatures=TeX]{Times New Roman}
\end{verbatim}
Package |fontspec| offers a lot of flexibility for the font selection,
see its documentation. 
%Another useful template is
% \begin{verbatim}
% \usepackage{fontspec}
% \defaultfontfeatures{Renderer=Basic,Ligatures={TeX}}
% \setmainfont{CMU Serif}
% \setsansfont{CMU Sans Serif}
% \setmonofont{CMU Typewriter Text}
% ...
% \usepackage[english,bulgarian]{babel}
% \end{verbatim}
% 

\paragraph{Compatibility mode}

Lualatex can be set up to use 8-bit fonts if the Unicode fonts do not
work for some reason. Note that the source file still needs to be in
UTF-8! Here is a template for this (the difference from \LaTeX{} is in
the second line):
\begin{verbatim}
  \usepackage[T1,T2A]{fontenc}
  \usepackage[lutf8]{luainputenc}
  \usepackage[english,bulgarian]{babel}
\end{verbatim}
The compatibility mode is a remedy for emergencies, not for routine
use. 


\subsection{Switching to and from Bulgarian language}
\label{sec:switch-from-bulg}

The language at the beginning of the document, i.e. after
|\begin{document}|, is determined by the options used to load package
  \babel. Several ways of changing the language are available,
  depending on what the user needs.



\subsubsection{The most common case}
\label{sec:typical-change}

In the most common case the user just wants to typeset some piece of
text in a different language, using the typesetting and hyphenation
rules of that language, without changing generic strings like
|\today|, names of sections and things like |\proofname| to the chosen
language.  This can be done with the command |\foreignlanguage| or the
environment |otherlanguage*|.

Here are some unimaginative examples to illustrate this.  Here is a
phrase in Bulgarian %we need to change to english to pretend
\selectlanguage{english}%that English is the main language!
  \foreignlanguage{bulgarian}{"`тази дата е форматирана по
    американския начин: \today"'},
\selectlanguage{bulgarian}
typeset in a sentence written in English. This phrase was typeset as
follows: 
\begin{verbatim}
   \foreignlanguage{bulgarian}{"`тази дата е форматирана 
    по американския начин: \today"'}
\end{verbatim}
For longer pieces of text it is more convenient to use the equivalent
environment.
\begin{verbatim}
\begin{otherlanguage*}{bulgarian}
   Това е пример за американския начин за форматиране на дати: \today.
   А тук думата \proofname е отпечатана с командата |\proofname|.
\end{otherlanguage*}
\end{verbatim}
Notice the `*' in the name of the environment.
The result is:

\selectlanguage{english}
\begin{quote}
\begin{otherlanguage*}{bulgarian}
   Това е пример за американския начин за форматиране на дати: \today.
   А тук думата \proofname{} е отпечатана с командата |\proofname|.
\end{otherlanguage*}
\end{quote} 
\selectlanguage{bulgarian}


Notice that the date and the heading for a proof are still in English.
To change these and similar language dependent strings we need a total
change of language. This is discussed below.


\subsubsection{Total change of language}
\label{sec:total-change-lang}

The \babel{} system controls a number of typesetting features for each
language.  The command |\selectlanguage| is used to do a complete
change to a new language. For example, |\selectlanguage{bulgarian}|
switches every aspect of the \babel{} system to Bulgarian language. For
example, the following snippet: {
\begin{verbatim}
  \selectlanguage{bulgarian}
    Този документ е компилиран на \today.

    Думата "`\proofname"'{} е отпечатана с командата |\proofname|.
  \selectlanguage{english}
  Some English text...
\end{verbatim}
}

\noindent
produces:
\begin{quote}
  \selectlanguage{bulgarian}
   Този документ е компилиран на \today.

   Думата "`\proofname"'{} е отпечатана с командата |\proofname|.
   \selectlanguage{english}
   Some English text...
\end{quote}
\selectlanguage{bulgarian}


Compare the result here to the similar example in the previous
section. Now everything is changed, including |\today| and other
names.

\subsubsection{Compatibility commands for change of language}
\label{sec:comm-prov-bulg}

Version 1.1 of the Bulgarian style continues to provide a number of
additional commands for change of language.  They are kept mainly for
compatibility with older versions of the Bulgarian style and their use
is discouraged.

The command |\Bulgarian| changes only the hyphenation patterns and the
encoding. It does not make a complete change of language and is really
suitable for short fragments which do not contain special
features. This may cause trouble in some cases, e.g. with |aux| files.
Similarly, the command |\English| switches to the English language. It
is left for compatibility.


For historical and compatibility reasons with ancient version of the
Bulgarian style, there are also several abbreviations equivalent to
|\Bulgarian|. These are: |\Bul|, |\Bg|, |\cyrillictext|, |\cyr|.  Also,
|\selectbglanguage| is equivalent to |\selectlanguage{bulgarian}|.

Similarly, |\Eng| is equivalent to |\English| and |\selectenglanguage|
is equivalent to |\selectlanguage{english}|.






\subsection{Quotation marks}

Quotation marks with typographic quality used to be a problem in the
past. They were not available on typewrites and keyboards.  Moreover,
the opening quotes used in Bulgarian typesetting were not available in
the standard fonts and needed to be generated by other means.  With
modern computers, fonts and editing programs it is no longer a problem
to enter directly the correct opening and closing quotation marks,
especially when Unicode based encodigs are in use.

Nevertheless, commands and shorthands are convenient.  The special
commands for quotation marks available for the Bulgarian language are
shown in Table~\ref{tab:bulgarian-quote}.
\begin{table}[htb]
  \begin{center}
  \begin{tabular}{llp{8cm}}
   Command &amp; Shorthand &amp; Meaning \\ \hline
   |\glqq| &amp;  |"`| &amp; for German left double quotes (looks like,\kern-0.08em,).  \\
   |\grqq| &amp;  |"'| &amp; for German right double quotes (looks like ``).\\^^A%''
   |\flqq| &amp;  |"&lt;| &amp; for French left double quotes (looks like $&lt;\!\!&lt;$).\\
   |\frqq| &amp;  |"&gt;| &amp; for French right double quotes (looks like $&gt;\!\!&gt;$).\\
   |\dq|   &amp;       &amp; the original quotes character (|"|).   % |
  \end{tabular}
  \caption{Special quotes available for Bulgarian typesetting}
  \label{tab:bulgarian-quote}
  \end{center}
\end{table}
The German quotes are the current norm. The French ones can be
found mostly in older texts.

The French quotes are also available as ligatures `|&lt;&lt;|' and
`|&gt;&gt;|' in 8-bit Cyrillic font encodings (\texttt{LCY},
\texttt{X2}, \texttt{T2*}) and as `|&lt;|' and `|&gt;|' characters in
7-bit Cyrillic font encodings (\texttt{OT2} and \texttt{LWN}).


\subsection{Hyphens and dashes}

The em-dash in Bulgarian texts is used for several purposes.
Table~\ref{tab:bulgarian-emdash} shows the available commands and
their intended contexts. The second column shows also the
shorthands that are usually used to enter these dashes.
\begin{table}[htb]
  \begin{center}
  \begin{tabular}{llp{7.8cm}}
   Command &amp; Shorthand &amp; Meaning \\ \hline
   |\cdash---| &amp; |"---| &amp; Cyrillic emdash in plain text.                \\
   |\cdash--~| &amp; |"--~| &amp; Cyrillic emdash in compound names (surnames). \\
   |\cdash--*| &amp; |"--*| &amp; Cyrillic emdash for denoting direct speech.
  \end{tabular}
  \caption{The emdashes available for Bulgarian typesetting}
  \label{tab:bulgarian-emdash}
  \end{center}
\end{table}


\subsection{Hyphenation control}

Table~\ref{tab:bulgarian-hyphen} gives commands for hyphenation
control. Most of them aim to facilitate hyphenation in compound words
and related circumstances.


\begin{table}
  \centering
  \begin{tabular}{ll}
    \LaTeX{} source    &amp; Typeset output \\ \hline
    |П. П. Славейков|    &amp; П. П. Славейков  \\
    |П.",П.",Славейков|  &amp; П.",П.",Славейков
  \end{tabular}
  \caption{Example for initials spaced out by ordinary space (first line) and the
    special command (second line). The command leaves a smaller, more visually
    appealing space. It also allows hyphenation of the surname, although
    this is not visible here.}
\end{table}

% П.",П.",Славейков

\begin{table}[htb]
  \begin{center}
  \begin{tabular}{lp{8cm}}
   Shorthand &amp; Meaning \\ \hline
   |"-| &amp; an explicit hyphen sign, allowing hyphenation
                   in the rest of the word.                      \\
   |""|  &amp; like |"-|, but producing no hyphen sign
                   (for compound words with hyphen, e.g.\ |x-""y|
                   or some other signs  as ``disable/enable'').  \\
   |"~|   &amp; for a compound word mark without a breakpoint.       \\
   |"=|   &amp; for a compound word mark with a breakpoint, allowing
                   hyphenation in the composing words.           \\
   |",|   &amp; thinspace for initials with a breakpoint
                   in following surname.                         \\
  \end{tabular}
  \caption{Extra definitions, mainly for hyphenation control}
  \label{tab:bulgarian-hyphen}
  \end{center}
\end{table}
Hyphenating words containing a hyphen is not particularly desirable
but may be necessary not only for long compounds words like
министър-председател (prime minister), but also for comparative and
superlative adjectives like по-""красноречива (more eloquent) or
най-""безопасният (the safest), since the Bulgarian equivalents of
`more' and `most' are connected to the adjective by a hyphen. Even so,
when the line width is not short, which is the case for this document,
\TeX{} is usually able to avoid hyphenating such words. In this
paragraph one of the example words is hyphenated only because I
deliberately edited it until this happened.


\subsection{Other shorthands}
%\label{sec:other-commands}

Table~\ref{tab:lig} gives some additional shorthands.
Currently there is only one entry and it concerns ligatures.
Ligatures are not common in Bulgarian texts. A ligature is used to
replace a sequence of two or more symbols by a more visually appealing
glyph. This topic is not of much importance for typesetting Bulgarian
texts and is beyond the scope of this document. 
For example, two dashes, `|--|', normally form a ligature to produce an
en-dash, `--'. The command \verb+"|+ provides a way to prevent the
formation of the ligature. So, `\verb+-"|-+'  gives
\DeleteShortVerb{\|}
 `-"|-'.
\MakeShortVerb{\|}   % |

\begin{table}[htb]   %   \label{tab:lig} - If I put the label here, the
                     %   reference to this table is with two numbers
                     %   like 2.5 rather than 5, as in other places!
                     %   :TODO: incestigate!
  \begin{center}
  \begin{tabular}{lp{8cm}}
   Shorthand &amp; Meaning \\ \hline
   \verb="|= &amp; disable ligature at this position.               
  \end{tabular}
  \caption{Extra shorthands.}
  \label{tab:lig}
  \end{center}
\end{table}

\subsection{Dates}
\label{sec:dates}

The command |\today| prints the current date. It is in Bulgarian if that
is the active language, see also Section~\ref{sec:switch-from-bulg}. 
Alternatively, the command |\todayRoman| prints the current date using
Roman numerals for months. 
So, when this document is compiled, |\today| and |\todayRoman|
give "`\today"' and "`\todayRoman"', respectively. 


Note: Following a suggestion by Boyko Bantchev, the space between the
year and `г.' was reduced in version 1.2b of this style. 

% \monthivname{}

The command |\weekdaynamebulgarian| can be used to typeset the names of
the days of the week. It is mostly intended for use in macros and has
one argument, the number of the required day of the week. For example, 
|\weekdaynamebulgarian{1}| and 
|\weekdaynamebulgarian{7}|
give 
\weekdaynamebulgarian{1} and 
\weekdaynamebulgarian{7},
respectively.

% \weekdayiname{} \weekdayiiname{}


\subsection{Enumerations}

The traditional alphabetical enumerations in Bulgarian texts use the
Cyrillic alphabet (bar several letters). In principle, enumerations are
a matter for class and style designers but the same can be said also
about things, other than enumerations, such as names of sections and
bibliography lists.
% The alphabet is not the only difference differences are not only
% in the letters --- Bulgarian authors generally prefer labels formatted
% as `a)' rather than `(a)'.

The Bulgarian style by default turns on enumeration with Cyrillic
letters. This means that enumerated lists that would be labelled with
Latin letters in Latin scripts are labelled with Cyrillic ones instead.

This automatic feature may not always be desirable, so Version 1.1d of
the Bulgarian style streamlines somewhat the support for Cyrillic
enumerations. For compatibility with older documents, the default is
still to turn on the Bulgarian enumerations when the active language is
Bulgarian but facilities to control this are provided.

The Cyrillic enumeration can also be turned on and off selectively for
parts of the document using the commands  |\abvon| and |\abvoff|.
The command |\abvoff| turns off the Cyrillic enumeration.
The command |\abvon| turns it on. It is thus possible to turn
the feature on and off for parts of the document. 

The user can turn off the Cyrillic enumeration by using attribute
`abvoff' when loading \babel, e.g.
\begin{verbatim}
   \usepackage[english,bulgarian .abvoff]{babel}
\end{verbatim}
The dot in front of the attribute's name is required and tells \babel{}
that this is an attribute.

\subsection{Mathematical functions}
\label{sec:math-funct}

The Bulgarian style provides definitions
for some mathematical functions whose names differ from the
corresponding English names. 

Currently these functions are: 
|\tg|,
|\ctg|,
|\cosec|,
|\arctg|,
|\arcctg|,
|\sh|,
|\ch|,
|\cth|.


\subsection{Troubleshooting}
\label{sec:handl-cyrill-lett}

The standard font encoding handling for Cyrillic letters in non-Uniceode
encodings is based on 
definitions like |\CYRA| for the Cyrillic letters. These are not
necessary for unicode engines (Luatex, XeTeX) but may still be
present in other packages (for example |varioref|) that handle
different languages by storing hard coded strings.

If your document is using a Unicode encoding, most likely UTF-8, and you
get errors like "`undefined command |\CYRA|"', then 
the command |\cyrxtounicode| may be used as an emergency patch.
It is not to be used routinely  as its use may hide
unrelated  bugs. Just put it at the beginning of your document.




\section{History}

\subsection{Changes in version 1.2}

The user visible changes are in the documentation. 

The minor version number was changed from 1 to 2 (hence 1.2 rather than
1.1) to accomodate a change in \babel{}~3.9g which removed the command
|UseStrings| and replaced it with a starred version of
\cs{StartBabelCommands}.


\subsection{Changes in version 1.1}

This is the first release after the individual languages were taken out
of the core \babel{} system (\babel{} version 3.9f). Some of the most
visible changes:

\begin{itemize}
\item Support for LuaTeX and XeTeX;
\item Documentation rewritten;
\item Facilities for turning on and off automatic Bulgarian enumeration;
\item Some long standing bugs fixed. In particular, it should no longer
  be necessary to load |amsmath| before \babel. 


\end{itemize}
For more details on the changes, see the "`Change history"' index at
the end of this document.


\subsection{Changes in version 1.0a--1.0g}

Bug fixes and small changes by Johannes Braams.


\subsection{Version 1.0}

Johannes Braams modified (and improved) the original draft to conform to
the \babel{} system and incorporated \file{\filename} into it.


\subsection{Older versions}

The first draft of the Bulgarian style for \babel{} was created by
modifying the August-1998 version of \file{russianb.dtx} for the
Bulgarian language along the lines of the 1994/1996 (non-babel)
Bulgarian style (\file{bulgaria.sty}) by Georgi N. Boshnakov.  It is
(reasonably) backward compatible with that style---files prepared for
that style should compile successfully (with vastly improved appearance
due to usage of standard fonts).

   % Users should take note of the vaious ``cyrillic'' dashes
   % available now (see below). These should remove many causes of
   % headache. Also, although by default the Bulgarian quotation marks
   % will appear automatically when typesetting in Bulgarian, it is
   % better to use the new commands |"`| and |"'| which
   % explicitly typeset them.
   % Note: automatic switch to Bulgarian quotation is withdrawn
   % for the moment and may not be reintroduced at all.
   % 



\DocInput{bulgarian.dtx}
\end{document}
%&lt;/filedriver&gt;
%\fi
%
% \StopEventually{}
%
% \GetFileInfo{bulgarian.dtx}
%
%    \section{Implementation}
%
% \changes{bulgarian-0.99}{2000/06/10}{
%   This is a prerelease version of this file.
%   Features needing further testing are removed.}
%
% \changes{bulgarian-1.2a}{2013/09/23}{Switch to babel 3.9g which
%   replaced \cs{UseStrings} with a mechanism based on starred 
%   \cs{StartBabelCommands}  commands.}
%
% \changes{bulgarian-1.2d}{2013/10/02}{Substantial clean-up of the
%   code and comments. In particular, removed commented out old code.} 
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
%
%    \begin{macrocode}
%&lt;*code&gt;
\LdfInit{bulgarian}{captionsbulgarian}
%    \end{macrocode}
%
%    When this file is read as an option, i.e., by the |\usepackage|
%    command, \texttt{bulgarian} will be an `unknown' language, in
%    which case we have to make it known. So we check for the
%    existence of |\l@bulgarian| to see whether we have to do
%    something here.
%
%    \begin{macrocode}
\ifx\l@bulgarian\@undefined
  \@nopatterns{Bulgarian}
  \adddialect\l@bulgarian0
\fi
%    \end{macrocode}
%
% New in version 1.1: detect luatex or xetex. The code is taken from
% russinab.dtx but the counter is renamed to avoid possible conflicts.
%    \begin{macrocode}
\newif\if@bul@unicode
\ifdefined\luatexversion \@bul@unicodetrue \else
\ifdefined\XeTeXrevision \@bul@unicodetrue \fi\fi
%    \end{macrocode}
%
%
%
% \subsection{Font encodings}
% \label{sec:font-encodings}
%
%
% \begin{macro}{\latinencoding}
% \changes{bulgarian-1.1}{2013/06/08}{Removed.}
%
% We need to know the fond encoding for text that is supposed to be
% active at the end of the \babel\ package. This is effectively assumed
% to be a Latin encoding and the macro \cs{latinencoding}, defined by
% \babel{}, contains the name of the Latin encoding. 
%
% \end{macro}
%
% \begin{macro}{\cyrillicencoding}
%   We need also to determine the encoding for Cyrillic text. It is
%   normally loaded by the |fontenc| package. These days it is usually
%   \texttt{T2A}.
%
%   We parse the |\cdp@list| containing the encodings known to \LaTeX\
%   in the order they were loaded. We set the |\cyrillicencoding| to the
%   \emph{last} loaded encoding in the list of supported Cyrillic
%   encodings: \texttt{OT2}, \texttt{LWN}, \texttt{LCY},
%   \texttt{X2}\footnote{Encoding \texttt{X2} does not contain Latin
%   letters and users should be very careful to switch the language
%   every time they want to typeset a Latin word inside a Bulgarian
%   phrase or vice versa.}, \texttt{T2C}, \texttt{T2B}, \texttt{T2A}, if
%   any.
%
%
%    \begin{macrocode}
\def\reserved@a#1#2{%
  \edef\reserved@b{#1}%
  \edef\reserved@c{#2}%
  \ifx\reserved@b\reserved@c
    \let\cyrillicencoding\reserved@c
  \fi}
\def\cdp@elt#1#2#3#4{%
  \reserved@a{#1}{OT2}%
  \reserved@a{#1}{LWN}%
  \reserved@a{#1}{LCY}%
  \reserved@a{#1}{X2}%
  \reserved@a{#1}{T2C}%
  \reserved@a{#1}{T2B}%
  \reserved@a{#1}{T2A}}
 \cdp@list
%    \end{macrocode}
%
% \changes{bulgarian-1.1b}{2013/06/12}{%
%       Changing completely the handling of the case when
%       \cs{cyrillicencoding} is not defined, see russianb.dtx.
%       The old code is commented out.}
%
% \changes{bulgarian-1.2d}{2013/10/02}{%
%   Deleted the the old code for the case when the user did not
%   specify font encoding (it had been already commented out in
%   version 1.1b).}
%
%   If |\cyrillicencoding| is undefined, then the user did not load any
%   of the supported encodings. The code below is new in version 1.1 of
%   this file and considers also the active \TeX{} engine.  It was
%   inspired by russianb.dtx.  We set a sensible default
%   |\cyrillicencoding| but still issue a warning to alert the user that
%   a default font encoding is used.
%    \begin{macrocode}
\ifx\cyrillicencoding\undefined
  \if@bul@unicode
    \ifdefined\XeTeXrevision
      \edef\cyrillicencoding{EU1}
    \else\ifdefined\luatexversion
      \edef\cyrillicencoding{EU2}
    \fi\fi
  \else
    \edef\cyrillicencoding{T2A}
  \fi
  \PackageWarning{bulgarian.ldf}%
    {No Cyrillic font encoding has been loaded so far.\MessageBreak
     A font encoding should be declared before babel.\MessageBreak
     Default `\cyrillicencoding' encoding will be loaded
    }%
%    \end{macrocode}
%
% We avoid |\usepackage[\cyrillicencoding]{fontenc}| because we
% don't want to force the switch of |\encodingdefault|.
%    \begin{macrocode}
  \lowercase\expandafter{\expandafter\input\cyrillicencoding enc.def\relax}%
\fi
%    \end{macrocode}
%
% \changes{bulgarian-1.1a}{2013/06/12}{PackageInfo was commented out, uncommented it}
%    \begin{macrocode}
\PackageInfo{babel}
     {Using `\cyrillicencoding' as a default Cyrillic encoding}%
%    \end{macrocode}
% \unskip
%
% \end{macro}
%
%   TODO: add |\English| to the extras for Bulgarian. It should not be
%   defined globally as it may be defined at a more appropriate place elsewhere.
%   In any case, the value of these abbreviations is limited as they do
%   not do a complete switch of language.
%   
%   The following commands are shorthands for switching to Bulgarian and
%   English. They are present here mainly for compatibility with older
%   versions of the Bulgarian style.
% \begin{macro}{\Bulgarian}
%   A simple switch to Bulgarian language:
%    \begin{macrocode}
\DeclareRobustCommand{\Bulgarian}{%
  \fontencoding\cyrillicencoding\selectfont
  \let\encodingdefault\cyrillicencoding
  \expandafter\set@hyphenmins\bulgarianhyphenmins
  \language\l@bulgarian}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\English}
%   A simple switch, similar to the above, but to the English language:
%    \begin{macrocode}
\DeclareRobustCommand{\English}{%
  \fontencoding\latinencoding\selectfont
  \let\encodingdefault\latinencoding
  \expandafter\set@hyphenmins\englishhyphenmins
  \language\l@english}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Bul}
% \begin{macro}{\Bg}
% \begin{macro}{\cyrillictext}
% \begin{macro}{\cyr}
% \begin{macro}{\Eng}
% \begin{macro}{\selectenglanguage}
% \begin{macro}{\selectbglanguage}
%   Finally, a few shorthands for switching the languages. These are
%   mostly remnants from pre-babel times.
%    \begin{macrocode}
\let\Bul\Bulgarian
\let\Bg\Bulgarian
\let\cyrillictext\Bulgarian
\let\cyr\Bulgarian
\let\Eng\English
\def\selectenglanguage{\selectlanguage{english}}
\def\selectbglanguage{\selectlanguage{bulgarian}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%\subsubsection{Adjustments for X2 encoding}
%
% The code in this section is executed only if the font encoding is
% \texttt{X2}
%
% Since the \texttt{X2} encoding does not contain Latin letters, we
% should make some redefinitions of \LaTeX\ macros which implicitly
% produce Latin letters.
%
%    \begin{macrocode}
\expandafter\ifx\csname T@X2\endcsname\relax\else
%    \end{macrocode}
%
%    We put |\latinencoding| in braces to avoid problems with |\@alph|
%    inside minipages (e.g., footnotes inside minipages) where
%    |\@alph| is expanded and we get for example `|\fontencoding OT1|'
%    (|\fontencoding| is robust).
%
% \changes{bulgarian-1.0c}{2003/06/14}{Added missing closing brace}
%    \begin{macrocode}
\def\@Alph@eng#1{{\fontencoding{\latinencoding}\selectfont \ifcase#1\or
    A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
    N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\else
    \@ctrerr\fi}}%
\def\@alph@eng#1{{\fontencoding{\latinencoding}\selectfont \ifcase#1\or
    a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or
    n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else
    \@ctrerr\fi}}%
  \let\@Alph\@Alph@eng
  \let\@alph\@alph@eng
%    \end{macrocode}
%
%    Unfortunately, the commands |\AA| and |\aa| are not encoding
%    dependent in \LaTeX\ (unlike e.g., |\oe| or |\DH|). They are
%    defined as |\r{A}| and |\r{a}|. This leads to unpredictable
%    results when the font encoding does not contain the Latin letters
%    `A' and `a' (like \texttt{X2}).
%
%    \begin{macrocode}
  \DeclareTextSymbolDefault{\AA}{OT1}
  \DeclareTextSymbolDefault{\aa}{OT1}
  \DeclareTextCommand{\AA}{OT1}{\r A}
  \DeclareTextCommand{\aa}{OT1}{\r a}
\fi
%    \end{macrocode}
%
%
% \changes{bulgarian-1.1a}{2013/06/12}{Commenting out the code in
%    section ``Some Greek letters for maths'', which is not needed any
%    more. This also resolves a trouble with amsmath, which made it
%    necessary in the past to load the latter before babel.}
%
% \changes{bulgarian-1.2d}{2013/10/02}{Removed section "`Some Greek
%    letters for maths"'. The command had already been commented out in
%    version 1.1a.}
%
%
%\subsection{Input encoding}
%
%
% For \LaTeX{}, pdf\LaTeX{}, and compatibility mode of Lua\LaTeX{}, the
% user should use the \pkg{inputenc} package (before loading \babel) to
% specify the encoding of the input file\footnote{After the changes in
% version 1.1b of |bulgarian.dtx|, if the font and input encoding are
% \texttt{T2A} and \texttt{cp1251}, respectively, the document might be
% processed correctly even without the |inputenc| package. Even so, it
% is better to be explicit about the input encoding.}.  For the Unicode
% engines this is not necessary, as they require Unicode based encoding.
% 
% We issue a warning if the input encoding has not been specified but do
% not consider this an error.
%
% \changes{bulgarian-1.1b}{2013/06/12}{Added EU1 and EU2 and removed
%   LWN} 
% \changes{bulgarian-1.1b}{2013/06/12}{Produce warning rather then
%   an error when inputenc has not been loaded}
%    \begin{macrocode}
\@ifpackageloaded{inputenc}{%
  \if@bul@unicode
   \PackageWarning{bulgarian.ldf}{inputenc should not be used with LuaTeX or XeTeX}
 \fi
}{%
  %\def\reserved@a{LWN}%
  %\ifx\reserved@a\cyrillicencoding\else
    \def\reserved@a{OT2}%
    \ifx\reserved@a\cyrillicencoding\else
       \def\reserved@a{EU1}%
       \ifx\reserved@a\cyrillicencoding\else
          \def\reserved@a{EU2}%
          \ifx\reserved@a\cyrillicencoding\else
             \PackageWarning{bulgarian.ldf}%
                {No input encoding specified for Bulgarian language}
    \fi\fi\fi
  %\fi
}
%    \end{macrocode}
%
%
% \begin{macro}{\cyrillictext}
% \begin{macro}{\latintext}
% \begin{macro}{\lat}
%
%\subsection{Switching between Cyrillic and Latin encodings}
%
% The command |\cyrillictext| will switch from Latin font encoding to
% the Cyrillic font encoding, the command |\latintext| switches back.
% We add the shorthand |\lat| for |\latintext|.  This assumes that the
% `normal' font encoding is a Latin one. These commands are
% \emph{declarations}, for shorter peaces of text the commands
% |\textlatin| and |\textcyrillic| can be used.
%
% |\latintext| is defined in the core of \babel, while |\cyrillictext|
% is defined above.
%
%    \begin{macrocode}
\let\lat\latintext
%    \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\textcyrillic}
% \begin{macro}{\textlatin}
%
%   These commands take an argument which is then typeset using the
%   requested font encoding.  |\textlatin| is defined in the core of
%   babel. (It is defined there with |\DeclareRobustCommand| instead.)
%
%    \begin{macrocode}
\DeclareTextFontCommand{\textcyrillic}{\cyrillictext}
%    \end{macrocode}
%
% \end{macro}
% \end{macro}
%
%
%
%\subsection{Captions for Bulgarian}
%
%
%
%    If  |\bbl@version| is undefined we use the old approach (using
%    |\addto| commands). 
%    \begin{macrocode}
\ifx\bbl@version\@undefined
\PackageInfo{bulgarian.ldf}{Executing the pre 3.9 branch for captions}
%    \end{macrocode}
%
%    \subsubsection{Captions for pre3.9 babel}
%
% \begin{macro}{\captionsbulgarian}
%
%    The macro |\captionsbulgarian| defines all strings used in the
%    four standard document classes provided with \LaTeX. The two
%    commands |\cyr| and |\lat| activate Cyrillic, resp. Latin, encoding.
%
%   \changes{bulgarian-1.1}{2013/06/08}{Added translation for Proof}
%   \changes{bulgarian-1.1}{2013/06/08}{Added translation for
%     Glossary. todo: need to check if this is appropriate.}
%    \begin{macrocode}
\addto\captionsbulgarian{%
  \def\prefacename{%
    {\cyr\CYRP\cyrr\cyre\cyrd\cyrg\cyro\cyrv\cyro\cyrr}}%
  \def\refname{%
    {\cyr\CYRL\cyri\cyrt\cyre\cyrr\cyra\cyrt\cyru\cyrr\cyra}}%
  \def\abstractname{%
    {\cyr\CYRA\cyrb\cyrs\cyrt\cyrr\cyra\cyrk\cyrt}}%
  \def\bibname{%
    {\cyr\CYRB\cyri\cyrb\cyrl\cyri\cyro\cyrg\cyrr\cyra\cyrf\cyri\cyrya}}%
  \def\chaptername{%
    {\cyr\CYRG\cyrl\cyra\cyrv\cyra}}%
  \def\appendixname{%
    {\cyr\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}}%
  \def\contentsname{%
    {\cyr\CYRS\cyrhrdsn\cyrd\cyrhrdsn\cyrr\cyrzh\cyra\cyrn\cyri\cyre}}%
  \def\listfigurename{%
    {\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ \cyrn\cyra\
      \cyrf\cyri\cyrg\cyru\cyrr\cyri\cyrt\cyre}}%
  \def\listtablename{%
    {\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ \cyrn\cyra\
      \cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyri\cyrt\cyre}}%
  \def\indexname{%
    {\cyr\CYRA\cyrz\cyrb\cyru\cyrch\cyre\cyrn\
      \cyru\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl}}%
  \def\authorname{%
    {\cyr\CYRI\cyrm\cyre\cyrn\cyre\cyrn\
      \cyru\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl}}%
  \def\figurename{%
    {\cyr\CYRF\cyri\cyrg\cyru\cyrr\cyra}}%
  \def\tablename{%
    {\cyr\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}}%
  \def\partname{%
    {\cyr\CYRCH\cyra\cyrs\cyrt}}%
  \def\enclname{%
    {\cyr\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}}%
  \def\ccname{%
    {\cyr\cyrk\cyro\cyrp\cyri\cyrya}}%
  \def\headtoname{%
    {\cyr\CYRZ\cyra}}%
  \def\pagename{%
    {\cyr\CYRS\cyrt\cyrr.}}%
  \def\seename{%
    {\cyr\cyrv\cyrzh.}}%
  \def\alsoname{%
    {\cyr\cyrv\cyrzh.\ \cyrs\cyrhrdsn\cyrshch\cyro\ \cyri}}%
  \def\proofname{%
    {\cyr\CYRD\cyro\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl\cyrs\cyrt\cyrv\cyro}}%
  \def\glossaryname{%
    {\cyr\CYRP\cyrr\cyri\cyrt\cyru\cyrr\cyrk\cyra}}% Glossary: Притурка, Глосар?
}%
%    \end{macrocode}
% \end{macro}
%%
%    \subsubsection{Captions for babel 3.9  or later}
%
%    \begin{macrocode}
\else
\PackageInfo{bulgarian.ldf}{Executing the post 3.9 branch for captions}
\StartBabelCommands*{bulgarian}{captions}[unicode, fontenc=EU1 EU2, charset=utf8]
  \SetString\prefacename{Предговор}
  \SetString\refname{Литература}
  \SetString\abstractname{Абстракт}
  \SetString\bibname{Библиография}
  \SetString\chaptername{Глава}
  \SetString\appendixname{Приложение} % todo: Апендикс ?
  \SetString\contentsname{Съдържание}
  \SetString\listfigurename{Списък на фигурите}
  \SetString\listtablename{Списък на таблиците}
  \SetString\indexname{Азбучен указател}
  \SetString\authorname{Именен указател}
  \SetString\figurename{Фигура}
  \SetString\tablename{Таблица}
  \SetString\partname{Част}
  \SetString\enclname{Приложения}
  \SetString\ccname{копия}
  \SetString\headtoname{За}
  \SetString\pagename{Стр.}  % todo: shouldn't this be all lowercase?
  \SetString\seename{вж.}
  \SetString\alsoname{вж. също и}
  \SetString\proofname{Доказателство}
  \SetString\glossaryname{Притурка}

\StartBabelCommands*{bulgarian}{captions}
  \SetString\prefacename{%
    {\cyr\CYRP\cyrr\cyre\cyrd\cyrg\cyro\cyrv\cyro\cyrr}}%
  \SetString\refname{%
    {\cyr\CYRL\cyri\cyrt\cyre\cyrr\cyra\cyrt\cyru\cyrr\cyra}}%
  \SetString\abstractname{%
    {\cyr\CYRA\cyrb\cyrs\cyrt\cyrr\cyra\cyrk\cyrt}}%
  \SetString\bibname{%
    {\cyr\CYRB\cyri\cyrb\cyrl\cyri\cyro\cyrg\cyrr\cyra\cyrf\cyri\cyrya}}%
  \SetString\chaptername{%
    {\cyr\CYRG\cyrl\cyra\cyrv\cyra}}%
  \SetString\appendixname{%
    {\cyr\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyre}}%
  \SetString\contentsname{%
    {\cyr\CYRS\cyrhrdsn\cyrd\cyrhrdsn\cyrr\cyrzh\cyra\cyrn\cyri\cyre}}%
  \SetString\listfigurename{%
    {\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ \cyrn\cyra\
      \cyrf\cyri\cyrg\cyru\cyrr\cyri\cyrt\cyre}}%
  \SetString\listtablename{%
    {\cyr\CYRS\cyrp\cyri\cyrs\cyrhrdsn\cyrk\ \cyrn\cyra\
      \cyrt\cyra\cyrb\cyrl\cyri\cyrc\cyri\cyrt\cyre}}%
  \SetString\indexname{%
    {\cyr\CYRA\cyrz\cyrb\cyru\cyrch\cyre\cyrn\
      \cyru\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl}}%
  \SetString\authorname{%
    {\cyr\CYRI\cyrm\cyre\cyrn\cyre\cyrn\
      \cyru\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl}}%
  \SetString\figurename{%
    {\cyr\CYRF\cyri\cyrg\cyru\cyrr\cyra}}%
  \SetString\tablename{%
    {\cyr\CYRT\cyra\cyrb\cyrl\cyri\cyrc\cyra}}%
  \SetString\partname{%
    {\cyr\CYRCH\cyra\cyrs\cyrt}}%
  \SetString\enclname{%
    {\cyr\CYRP\cyrr\cyri\cyrl\cyro\cyrzh\cyre\cyrn\cyri\cyrya}}%
  \SetString\ccname{%
    {\cyr\cyrk\cyro\cyrp\cyri\cyrya}}%
  \SetString\headtoname{%
    {\cyr\CYRZ\cyra}}%
  \SetString\pagename{%
    {\cyr\CYRS\cyrt\cyrr.}}%
  \SetString\seename{%
    {\cyr\cyrv\cyrzh.}}%
  \SetString\alsoname{%
    {\cyr\cyrv\cyrzh.\ \cyrs\cyrhrdsn\cyrshch\cyro\ \cyri}}%
  \SetString\proofname{%
    {\cyr\CYRD\cyro\cyrk\cyra\cyrz\cyra\cyrt\cyre\cyrl\cyrs\cyrt\cyrv\cyro}}%
  \SetString\glossaryname{%
    {\cyr\CYRP\cyrr\cyri\cyrt\cyru\cyrr\cyrk\cyra}}% Glossary: Притурка, Глосар?
\EndBabelCommands
\fi
%    \end{macrocode}
%
%
%\subsection{Dates in Bulgarian}
%
% \changes{bulgarian-1.2b}{2013/09/26}{Change the ordinary space between
%   the date and g. to \cs{,} in \cs{today} and \cs{todayRoman} (suggested
%   by Boyko Bantchev).}
%
%    The month is often written with Roman numbers in Bulgarian dates.
%    Below we define a version of \cs{today} in this format but here we
%    define a couple of potentially useful general commands.
%
% \begin{macro}{\month@Roman}
% \begin{macro}{\Romannumeral}
%   |\Romannumeral| converts its argument to a capitalized Roman numeral.
%   |\month@Roman| gives the current month using capital Roman
%   numerals.
%    \begin{macrocode}
\def\month@Roman{\expandafter\@Roman\month}%
\def\Romannumeral#1{\uppercase\expandafter{\romannumeral #1}}
%%% 2013-10-02 comment this out (it is repeated below):
%%% \def\todayRoman{\number\day.\Romannumeral{\month}.\number\year\,\cyrg.}
%    \end{macrocode}
%
% \end{macro}
% \end{macro}
%
%    Define the dates of the switch from Julian to Gregorian calendar in Bulgaria. 
% \begin{macro}{\lastJulianDatebulgarian}
%   \changes{bulgarian-1.2e}{2013/10/10}{New macro.}
% \begin{macro}{\firstGregorianDatebulgarian}
%   \changes{bulgarian-1.2e}{2013/10/10}{New macro.}
% \begin{macro}{\weekdaynamebulgarian}
%   \changes{bulgarian-1.2e}{2013/10/10}{New macro.}
%    \begin{macrocode}
\def\lastJulianDatebulgarian{19160331}
\def\firstGregorianDatebulgarian{19160414}
\def\weekdaynamebulgarian#1{\csname weekday\romannumeral#1 name\endcsname}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    \subsubsection{Dates for pre3.9 babel}
%
%    We use the new mechanism provided by \babel~v3.9 but for backward
%    compatibility, at least until version v3.9 of \babel{} becomes
%    ubiquitous we keep old code. The macro |\bbl@version| is undefined
%    in \babel{} versions prior to 3.9, so we use it.
%
%    If  |\bbl@version| is undefined we use the old approach
%    \begin{macrocode}
\ifx\bbl@version\@undefined
\PackageInfo{bulgarian.ldf}{Executing the pre 3.9 branch for dates}
%    \end{macrocode}
%
% \begin{macro}{\datebulgarian}
%
%    The macro |\datebulgarian| redefines the command |\today| to
%    produce Bulgarian dates.
%    It also provides the command |\todayRoman| which produces the
%    date with the month in capital roman numerals, a popular format
%    for dates in Bulgarian.
%
%    \begin{macrocode}
\def\datebulgarian{%
  \def\month@bulgarian{\ifcase\month\or
    \cyrya\cyrn\cyru\cyra\cyrr\cyri\or
    \cyrf\cyre\cyrv\cyrr\cyru\cyra\cyrr\cyri\or
    \cyrm\cyra\cyrr\cyrt\or
    \cyra\cyrp\cyrr\cyri\cyrl\or
    \cyrm\cyra\cyrishrt\or
    \cyryu\cyrn\cyri\or
    \cyryu\cyrl\cyri\or
    \cyra\cyrv\cyrg\cyru\cyrs\cyrt\or
    \cyrs\cyre\cyrp\cyrt\cyre\cyrm\cyrv\cyrr\cyri\or
    \cyro\cyrk\cyrt\cyro\cyrm\cyrv\cyrr\cyri\or
    \cyrn\cyro\cyre\cyrm\cyrv\cyrr\cyri\or
    \cyrd\cyre\cyrk\cyre\cyrm\cyrv\cyrr\cyri\fi}%
  \def\abbgyear{\cyrg.}

  \def\today{\number\day~\month@bulgarian\ \number\year\,\abbgyear}%
  \def\todayRoman{\number\day.\,\month@Roman.\,\number\year\,\abbgyear}%
}%
%    \end{macrocode}
%
% \end{macro}
%
%    \subsubsection{Dates for babel 3.9  or later}
%
% \changes{bulgarian-1.2e}{2013/10/04}{Use \cs{SetStringLoop} for months}
% \changes{bulgarian-1.2e}{2013/10/04}{Introduce names of days of week}
%
%    \begin{macrocode}
\else
\PackageInfo{bulgarian.ldf}{Executing the post 3.9 branch for dates}
\StartBabelCommands*{bulgarian}{date}[unicode, fontenc=EU1 EU2, charset=utf8]
  \SetStringLoop{month#1name}{%
    януари,февруари,март,април,май,юни,%
    юли,август,септември,октомври,ноември,декември}

  \SetStringLoop{weekday#1name}{%
    понеделник,вторник,сряда,четвъртък,петък,събота,неделя}

  \SetString\abbgyear{г.}
%    \end{macrocode}
% The following |\if| clause is a patch.
% |\if@bul@unicode| ensures that the following will not be executed
% Unicode engines are in use. It should not be anyway but
% |\SetStringLoop| seems to expand its argument prematurely and |\cyrya|
% etc. are not defined for Unicode engines. 
% 
% \changes{bulgarian-1.2f}{2013/10/13}{(bug fix) put \cs{if@bul@unicode} 
%   before \cs{StartBabelCommands} (the dates one)
%   to avoid an error when processing with Luatex.}
% 
%    \begin{macrocode}
\StartBabelCommands*{bulgarian}{date}
%%% %(princ (to-cyrx-string bulmonths))
\if@bul@unicode
\else
  \SetStringLoop{month#1name}{%
    \cyrya\cyrn\cyru\cyra\cyrr\cyri,\cyrf\cyre\cyrv\cyrr\cyru\cyra\cyrr\cyri,%
    \cyrm\cyra\cyrr\cyrt,\cyra\cyrp\cyrr\cyri\cyrl,\cyrm\cyra\cyrishrt,%
    \cyryu\cyrn\cyri,\cyryu\cyrl\cyri,\cyra\cyrv\cyrg\cyru\cyrs\cyrt,%
    \cyrs\cyre\cyrp\cyrt\cyre\cyrm\cyrv\cyrr\cyri,%
    \cyro\cyrk\cyrt\cyro\cyrm\cyrv\cyrr\cyri,%
    \cyrn\cyro\cyre\cyrm\cyrv\cyrr\cyri,\cyrd\cyre\cyrk\cyre\cyrm\cyrv\cyrr\cyri}%
%%% %(princ (to-cyrx-string "понеделник,вторник,сряда,четвъртък,петък,събота,неделя"))
  \SetStringLoop{weekday#1name}{%
    \cyrp\cyro\cyrn\cyre\cyrd\cyre\cyrl\cyrn\cyri\cyrk,%
    \cyrv\cyrt\cyro\cyrr\cyrn\cyri\cyrk,\cyrs\cyrr\cyrya\cyrd\cyra,%
    \cyrch\cyre\cyrt\cyrv\cyrhrdsn\cyrr\cyrt\cyrhrdsn\cyrk,%
    \cyrp\cyre\cyrt\cyrhrdsn\cyrk,\cyrs\cyrhrdsn\cyrb\cyro\cyrt\cyra,%
    \cyrn\cyre\cyrd\cyre\cyrl\cyrya}%
\fi

   \SetString\abbgyear{\cyrg.}

  \SetString\today{\number\day~%
    \csname month\romannumeral\month name\endcsname\space
    \number\year\,\abbgyear}

  \SetString\todayRoman{\number\day.\,\month@Roman.\,\number\year\,\abbgyear}
%    \end{macrocode}
%    \begin{macrocode}
\EndBabelCommands
\fi
%    \end{macrocode}


%
%\subsection{Extras for Bulgarian}
%
%
% \begin{macro}{\extrasbulgarian}
%
%    The macro |\extrasbulgarian| will perform all the extra
%    definitions needed for the Bulgarian language.
%    The macro |\noextrasbulgarian| is used to cancel the actions of
%    |\extrasbulgarian|.
%
%    The first action we define is to switch on the selected Cyrillic
%    encoding whenever we enter `bulgarian'.
%
%    \begin{macrocode}
\addto\extrasbulgarian{\cyrillictext}
%    \end{macrocode}
%
% When the encoding definition file was processed by \LaTeX\ the current
% font encoding is stored in |\latinencoding|. We switch back to
% |\latinencoding| whenever the Bulgarian language is no longer
% `active'.
%
%    \begin{macrocode}
\addto\noextrasbulgarian{\latintext}
%    \end{macrocode}
%
%    For Bulgarian, the \texttt{"} character is made active. 
%    The user part of the documentation gives an overview of the
%    available shorthands,  see  Table~\ref{tab:bulgarian-quote}.
%
%    \begin{macrocode}
\initiate@active@char{"}
%    \end{macrocode}
%
% We specify that the Bulgarian group of shorthands should be used.
%
%    \begin{macrocode}
\addto\extrasbulgarian{\languageshorthands{bulgarian}}
%    \end{macrocode}
%
%    These characters are `turned on' once, later their definition may
%    vary.
%
%    \begin{macrocode}
\addto\extrasbulgarian{%
  \bbl@activate{"}}
\addto\noextrasbulgarian{%
  \bbl@deactivate{"}}
%    \end{macrocode}
%
%    To be able to define the function of `|"|', we first define a
%    couple of `support' macros.
%
% \begin{macro}{\dq}
%
%    We save the original double quote character in |\dq| to keep it
%    available, the math accent |\"|can now be typed as `|"|'.
% \changes{bulgarian-1.0c}{2003/04/10}{repaired typo}
%    \begin{macrocode}
\begingroup \catcode`\"12
\def\reserved@a{\endgroup
  \def\@SS{\mathchar"7019}
  \def\dq{"}}
\reserved@a
%    \end{macrocode}
%
% \end{macro}
%
%    Now we can define the doublequote macros: german and french
%    quotes. We use definitions of these quotes made in babel.sty.
%    The french quotes are contained in the \texttt{T2*} encodings.
%
%    \begin{macrocode}
\declare@shorthand{bulgarian}{"`}{\glqq}
\declare@shorthand{bulgarian}{"'}{\grqq}
\declare@shorthand{bulgarian}{"&lt;}{\flqq}
\declare@shorthand{bulgarian}{"&gt;}{\frqq}
%    \end{macrocode}
%
%    Some additional commands:
%
%    \begin{macrocode}
\declare@shorthand{bulgarian}{""}{\hskip\z@skip}
\declare@shorthand{bulgarian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
\declare@shorthand{bulgarian}{"=}{\nobreak-\hskip\z@skip}
\declare@shorthand{bulgarian}{"|}{% |
\textormath{\nobreak\discretionary{-}{}{\kern.03em}%
\allowhyphens}{}}
%    \end{macrocode}
%
%    The next two macros for |"-| and |"---| are somewhat different.
%    We must check whether the second token is a hyphen character:
%
%    \begin{macrocode}
\declare@shorthand{bulgarian}{"-}{%
%    \end{macrocode}
%
%    If the next token is `|-|', we typeset an emdash, otherwise a
%    hyphen sign:
%
%    \begin{macrocode}
  \def\bulgarian@sh@tmp{%
    \if\bulgarian@sh@next-\expandafter\bulgarian@sh@emdash
    \else\expandafter\bulgarian@sh@hyphen\fi
  }%
%    \end{macrocode}
%
%    \TeX\ looks for the next token after the first `|-|': the meaning
%    of this token is written to |\bulgarian@sh@next| and
%    |\bulgarian@sh@tmp| is called.
%
%    \begin{macrocode}
  \futurelet\bulgarian@sh@next\bulgarian@sh@tmp}
%    \end{macrocode}
%
%    Here are the definitions of hyphen and emdash. First the hyphen:
%
%    \begin{macrocode}
\def\bulgarian@sh@hyphen{\nobreak\-\bbl@allowhyphens}
%    \end{macrocode}
%
%    For the emdash definition, there are the two parameters: we must
%    `eat' two last hyphen signs of our emdash \dots :
%
%    \begin{macrocode}
\def\bulgarian@sh@emdash#1#2{\cdash-#1#2}
%    \end{macrocode}
%
% \begin{macro}{\cdash}
%
%    \dots\ these two parameters are useful for another macro:
%    |\cdash|:
%
% \changes{bulgarian-1.0e}{2006/03/31}{Two occurences of \cmd{temp}
%    were changed into tab followed by emp}
%    \begin{macrocode}
\ifx\cdash\undefined % should be defined earlier
\def\cdash#1#2#3{\def\tempx@{#3}%
\def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
 \ifx\tempx@\tempa@\@Acdash\else
  \ifx\tempx@\tempb@\@Bcdash\else
   \ifx\tempx@\tempc@\@Ccdash\else
    \errmessage{Wrong usage of cdash}\fi\fi\fi}
%    \end{macrocode}
%
%  second parameter (or third for |\cdash|) shows what kind of emdash
%  to create in next step
%  \begin{center}
%  \begin{tabular}{@{}p{.1\hsize}@{}p{.9\hsize}@{}}
%   |"---| &amp; ordinary (plain) Cyrillic emdash inside text:
%   an unbreakable thinspace will be inserted before only in case of
%   a \textit{space} before the dash (it is necessary for dashes after
%   display maths formulae: there could be lists, enumerations etc.\
%   started with ``---where $a$ is ...'' i.e., the dash starts a line).
%   (Firstly there were planned rather soft rules for user:he may put
%   a space before the dash or not. But it is difficult to place this
%   thinspace automatically, i.e., by checking modes because after
%   display formulae \TeX{} uses horizontal mode. Maybe there is a
%   misunderstanding? Maybe there is another way?) After a dash
%   a breakable thinspace is always placed; \\
%  \end{tabular}
%  \end{center}
%
%
%    \begin{macrocode}
\def\@Acdash{\ifdim\lastskip&gt;\z@\unskip\nobreak\hskip.2em\fi
\cyrdash\hskip.2em\ignorespaces}%
%    \end{macrocode}
%
%      \begin{center}
%      \begin{tabular}{@{}p{.1\hsize}@{}p{.9\hsize}@{}}
%       |"--~| &amp; emdash in compound names or surnames
%       (like Mendeleev--Klapeiron); this dash has no space characters
%       around; after the dash some space is added by |\exhyphenpenalty|.
%      \end{tabular}
%      \end{center}
%
%    \begin{macrocode}
\def\@Bcdash{\leavevmode\ifdim\lastskip&gt;\z@\unskip\fi
 \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z@skip\ignorespaces}%
%    \end{macrocode}
%
%    \begin{center}
%    \begin{tabular}{@{}p{.1\hsize}@{}p{.9\hsize}@{}}
%     |"--*| &amp; for denoting direct speech (a space like |\enskip|
%     must follow the emdash); \\
%    \end{tabular}
%    \end{center}
%
%    \begin{macrocode}
\def\@Ccdash{\leavevmode
 \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
%\fi
%    \end{macrocode}
%
% \end{macro}
%
%
%
% \begin{macro}{\cyrdash}
%
%    Finally the macro for ``body'' of the Cyrillic emdash.
%    The |\cyrdash| macro will be defined in case this macro hasn't
%    been defined in a fontenc file. For T2*fonts, cyrdash will be
%    placed in the code of the English emdash thus it uses ligature
%    |---|.
%
%    \begin{macrocode}
% Is there an IF necessary?
\ifx\cyrdash\undefined
\def\cyrdash{\hbox to.8em{--\hss--}}
\fi
%    \end{macrocode}
%
% \end{macro}
%
%    Here a really new macro---to place thinspace between initials.
%    This macro used instead of |\,| allows hyphenation in the
%    following surname.
%
%    \begin{macrocode}
\declare@shorthand{bulgarian}{",}{\nobreak\hskip.2em\ignorespaces}
%    \end{macrocode}
%
%    The Bulgarian hyphenation patterns can be used with
%    |\lefthyphenmin|\footnote{Actually, it seems that the "`official"'
%    definition allows even one character for |lefthyphen| but I have
%    not investigated this completely.} and |\righthyphenmin| set to~2.
% \changes{bulgarian-1.0b}{2000/09/22}{Now use \cs{providehyphenmins} to
%    provide a default value}
%    \begin{macrocode}
\providehyphenmins{\CurrentOption}{\tw@\tw@}
\fi
%    \end{macrocode}
%
%    Bulgarian typesetting requires |frenchspacing|. So, we add commands
%    to |\extrasbulgarian| and |\noextrasbulgarian| to turn it on and
%    off, respectively.
%
%    \begin{macrocode}
\addto\extrasbulgarian{\bbl@frenchspacing}
\addto\noextrasbulgarian{\bbl@nonfrenchspacing}
%    \end{macrocode}
%
% \changes{bulgarian-1.2d}{2013/10/02}{Removed the code that made two
%   single quotes automatically produce Bulgarian quotes in Bulgarian
%   text. That code had been commented out for many years, possibly to
%   avoid introducing to additional active characters.}
% 
%
% \end{macro}
%
%    \subsection{Enumerations for Bulgarian}
%
% \changes{bulgarian-1.1d}{2013/06/13}{Major rewrite of code and
%    documentation for Bulgarian enumerations.}
%
% \begin{macro}{\@Alph@bul}
%
% \changes{bulgarian-1.1d}{2013/06/13}{New: support for Unicode based
%    engines.}
%
%   We begin by defining |\@Alph@bul| which works like |\@Alph|, but
%   produces (uppercase) Cyrillic letters intead of Latin ones. The
%   letters й, ъ and ы (ISHRT, HRDSN and SFTSN) are skipped, as usual
%   for this kind of enumeration. Note that these macros do not switch
%   encodings (and never did)\footnote{Earlier in this file, there are
%   definitions of {|@Alph@eng|} and |@alph@eng| in the code for
%   handling the obsolete cyrillic encoding |X2|. They contain encoding
%   commands. This is necessary for |X2| since it does not contain Latin
%   letters. These precautions hardly had any effect before the changes
%   for versions 1.1, since the old code below was effectively
%   overwriting them. The changes to |\@Alph| and |\@alph| are now
%   honoured as a side effect of the changes.}.
%
%    \begin{macrocode}
\if@bul@unicode
  \def\@Alph@bul#1{\ifcase#1\or
    А\or Б\or В\or Г\or Д\or Е\or Ж\or
    З\or И\or К\or Л\or М\or Н\or О\or
    П\or Р\or С\or Т\or У\or Ф\or Х\or
    Ц\or Ч\or Ш\or Щ\or Ю\or Я\else
    \@ctrerr\fi}
\else
  \def\@Alph@bul#1{\ifcase#1\or
    \CYRA\or \CYRB\or \CYRV\or \CYRG\or \CYRD\or \CYRE\or \CYRZH\or
    \CYRZ\or \CYRI\or \CYRK\or \CYRL\or \CYRM\or \CYRN\or \CYRO\or
    \CYRP\or \CYRR\or \CYRS\or \CYRT\or \CYRU\or \CYRF\or \CYRH\or
    \CYRC\or \CYRCH\or \CYRSH\or \CYRSHCH\or \CYRYU\or \CYRYA\else
    \@ctrerr\fi}
\fi
%    \end{macrocode}
%
% \end{macro}
%
%
% \begin{macro}{\@alph@bul}
%
% \changes{bulgarian-1.1d}{2013/06/13}{New: support for Unicode based
%    engines.}
%
%    The macro |\@alph@bul| is similar to |\@Alph@bul|
%    but produces lowercase Bulgarian letters.
%
%    \begin{macrocode}
\if@bul@unicode
  \def\@alph@bul#1{\ifcase#1\or
    а\or б\or в\or г\or д\or е\or ж\or
    з\or и\or к\or л\or м\or н\or о\or
    п\or р\or с\or т\or у\or ф\or х\or
    ц\or ч\or ш\or щ\or э\or ю\or я\else\@ctrerr\fi}
\else
  \def\@alph@bul#1{\ifcase#1\or
    \cyra\or \cyrb\or \cyrv\or \cyrg\or \cyrd\or \cyre\or \cyrzh\or
    \cyrz\or \cyri\or \cyrk\or \cyrl\or \cyrm\or \cyrn\or \cyro\or
    \cyrp\or \cyrr\or \cyrs\or \cyrt\or \cyru\or \cyrf\or \cyrh\or
    \cyrc\or \cyrch\or \cyrsh\or \cyrshch\or \cyryu\or \cyrya\else
    \@ctrerr\fi}
\fi
%    \end{macrocode}
%
% \end{macro}
%
%
% \begin{macro}{\@Alph@eng}
% \changes{bulgarian-1.1d}{2013/06/13}{Do not define this from
%    scratch}
%
% \begin{macro}{\@alph@eng}
% \changes{bulgarian-1.1d}{2013/06/13}{Do not define this from
%    scratch}
%
%    We no longer define English |\@Alph@eng| and |\@alph@eng| from
%    scratch. We copy the definitions active at the time this file is
%    loaded.
%    \begin{macrocode}
\let\@Alph@eng\@Alph
\let\@alph@eng\@alph
%    \end{macrocode}
%    For version 1.1d we store the original definitions in the following
%    macros. TODO: there is redundancy but need to check before removing
%    stuff.
%    \begin{macrocode}
\let\@Alph@saved\@Alph
\let\@alph@saved\@alph
%    \end{macrocode}
% \end{macro}
% \end{macro}
%%%
%%%  The old code for defining |\@Alph@eng| and |\@alph@eng| is commented out.
%%%    \begin{macrocode}
%%\def\@Alph@eng#1{%
%%  \ifcase#1\or
%%  A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or
%%  N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\else
%%  \@ctrerr\fi
%%  }
%%\def\@alph@eng#1{%
%%  \ifcase#1\or
%%  a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or
%%  n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else
%%  \@ctrerr\fi
%%  }
%%%    \end{macrocode}
%%%
%    We define commands for manually switching to and from English based
%    enumeration. Note that this definition for |\enumBul| is really
%    suitable for switching back after using |\enumEng|, since
%    |\enumBul| does not specify encoding and therefore would give an
%    error if called when the active encoding does not know cyrillic
%    (but see the similar code for X2 which does take care of the encoding).
%    \begin{macrocode}
\def\enumBul{\let\@Alph\@Alph@bul \let\@alph\@alph@bul}
\def\enumEng{\let\@Alph\@Alph@eng \let\@alph\@alph@eng}
\def\enumLat{\let\@Alph\@Alph@eng \let\@alph\@alph@eng}
%    \end{macrocode}
%
%
% \begin{macro}{\abvon}
% \changes{bulgarian-1.1d}{2013/06/15}{New macro.}
% \begin{macro}{\abvoff}
% \changes{bulgarian-1.1d}{2013/06/15}{New macro.}
%   Commands are provided for manual switching on and off of the
%   enumeration with Cyrillic letters: |\abvon| turns it on, while
%   |\abvoff| turns it off.  
%    \begin{macrocode}
\def\abvon{\let\@Alph@saved\@Alph \let\@alph@saved\@alph \enumBul}
\def\abvoff{\let\@Alph\@Alph@saved \let\@alph\@alph@saved}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    By default the  Bulgarian enumeration scheme is turned on when
%    switching to Bulgarian. 
%    todo: Could avoid adding to |noextrasbulgarian| by using |babel@save| in
%    the first command. TODO: there should be a better way to do this
%    but I do not know of a portable way to check if the user has
%    supplied the attribute `abvoff'. (Attributes are processed by babel
%    after it is loaded.)
%
%    \changes{bulgarian-1.1d}{2013/06/13}{Introduced attributes {abvon} and {abvoff}}
%    \begin{macrocode}
\def\autoabvon{\abvon}
\def\autoabvoff{\abvoff}
\addto\extrasbulgarian{\autoabvon}
\addto\noextrasbulgarian{\autoabvoff}
%    \end{macrocode}
%
%
%    The user can stop babel from turning on the Cyrillic enumeration
%    style by using attribute `abvoff' when loading babel.
%    \begin{macrocode}
\bbl@declare@ttribute{bulgarian}{abvoff}{%
  \PackageInfo{babel}{Turned off automatic Cyrillic enumeration in
    Bulgarian}%
  \def\autoabvon{\relax}
  \def\autoabvoff{\relax}
  \def\abvon{\enumBul}
}
%    \end{macrocode}
%
%
%
%\subsection{Cyrillic letters in maths}
%
%
%    Set up default Cyrillic math alphabets. To use Cyrillic letters
%    in math mode user should load the |textmath| package
%    \emph{before} loading fontenc package (or \babel). Note that by
%    default Cyrillic letters are taken from upright font in math mode
%    (unlike Latin letters).
%
%    \begin{macrocode}
%\RequirePackage{textmath}
\@ifundefined{sym\cyrillicencoding letters}{}{%
\SetSymbolFont{\cyrillicencoding letters}{bold}\cyrillicencoding
  \rmdefault\bfdefault\updefault
\DeclareSymbolFontAlphabet\cyrmathrm{\cyrillicencoding letters}
%    \end{macrocode}
%
% \begin{macro}{\cyrmathbf}
% \begin{macro}{\cyrmathsf}
% \begin{macro}{\cyrmathit}
% \begin{macro}{\cyrmathtt}
%    And we need a few commands to be able to switch to different
%    variants.
%
%    \begin{macrocode}
\DeclareMathAlphabet\cyrmathbf\cyrillicencoding
  \rmdefault\bfdefault\updefault
\DeclareMathAlphabet\cyrmathsf\cyrillicencoding
  \sfdefault\mddefault\updefault
\DeclareMathAlphabet\cyrmathit\cyrillicencoding
  \rmdefault\mddefault\itdefault
\DeclareMathAlphabet\cyrmathtt\cyrillicencoding
  \ttdefault\mddefault\updefault
%    \end{macrocode}
%
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%    We define also some bold variants.
%    \begin{macrocode}
\SetMathAlphabet\cyrmathsf{bold}\cyrillicencoding
  \sfdefault\bfdefault\updefault
\SetMathAlphabet\cyrmathit{bold}\cyrillicencoding
  \rmdefault\bfdefault\itdefault
}
%    \end{macrocode}
%
%\subsection{Alternative names for math functions}
%
% \changes{bulgarian-1.1c}{2013/06/13}{Rewrote the text and rearranged
%     the code for the math operators}
%
%     Here we define some math operator names in accordance with Bulgarian
%     typesetting traditions.
% \begin{macro}{\tg}
% \begin{macro}{\ctg}
% \begin{macro}{\cosec}
% \begin{macro}{\arctg}
% \begin{macro}{\arcctg}
% \begin{macro}{\sh}
% \begin{macro}{\ch}
% \begin{macro}{\cth}
%    Some math functions in Bulgarian have other names, e.g.
%    \texttt{sinh} is written as \texttt{sh}, etc. We define here
%    alternative math operators for |\tan|, |\cot|, |\csc|, |\arctan|,
%    |\arccot|, |\sinh|, |\cosh|, |\coth|, and |\tanh|.
%    \begin{macrocode}
\def\tg{\mathop{\operator@font tg}\nolimits}
\def\ctg{\mathop{\operator@font ctg}\nolimits}
\def\cosec{\mathop{\operator@font cosec}\nolimits}
\def\arctg{\mathop{\operator@font arctg}\nolimits}
\def\arcctg{\mathop{\operator@font arcctg}\nolimits}
\def\sh{\mathop{\operator@font sh}\nolimits}
\def\ch{\mathop{\operator@font ch}\nolimits}
\def\cth{\mathop{\operator@font cth}\nolimits}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\th}
%   The macro |\th| conflicts with |\th| defined in Latin~1 encoding. We
%   define it as the hyperbolic tangent in math mode but keep the
%   existing definition for text.
% \changes{bulgarian-1.0d}{2004/05/21}{Change definition of \cs{th}
%    only for this language.}
% \changes{bulgarian-1.1a}{2013/06/08}{Add the local definition 
%    to extrasbulgarian, not extrasrussian.}
%    \begin{macrocode}
\addto\extrasbulgarian{%
  \babel@save{\th}%
  \let\ltx@th\th
  \def\th{\textormath{\ltx@th}%
                     {\mathop{\operator@font th}\nolimits}}%
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cyrxtounicode}
%    The standard font encoding handling for Cyrillic letters uses
%    definitions like |\CYRA| for the Cyrillic letters. These are not
%    necessary for unicode engines (Luatex, XeTeX) but may still be
%    present in other packages (for example |varioref|) that handle
%    different languages by storing hard coded strings.
%
%    The following command may be used as emergency patch for such
%    problems. It is not to be used routinely  as its use may hide
%    unrelated  bugs.
%    \begin{macrocode}
\def\cyrxtounicode{%
  \let\CYRA=А \let\CYRB=Б \let\CYRV=В \let\CYRG=Г \let\CYRD=Д
  \let\CYRE=Е \let\CYRZH=Ж \let\CYRZ=З \let\CYRI=И \let\CYRISHRT=Й
  \let\CYRK=К \let\CYRL=Л \let\CYRM=М \let\CYRN=Н \let\CYRO=О
  \let\CYRP=П \let\CYRR=Р \let\CYRS=С \let\CYRT=Т \let\CYRU=У
  \let\CYRF=Ф \let\CYRH=Х \let\CYRC=Ц \let\CYRCH=Ч \let\CYRSH=Ш
  \let\CYRSHCH=Щ \let\CYRHRDSN=Ъ \let\CYRSFTSN=Ь \let\CYRYU=Ю
  \let\CYRYA=Я
  \let\cyra=а \let\cyrb=б \let\cyrv=в \let\cyrg=г \let\cyrd=д
  \let\cyre=е \let\cyrzh=ж \let\cyrz=з \let\cyri=и \let\cyrishrt=й
  \let\cyrk=к \let\cyrl=л \let\cyrm=м \let\cyrn=н \let\cyro=о
  \let\cyrp=п \let\cyrr=р \let\cyrs=с \let\cyrt=т \let\cyru=у
  \let\cyrf=ф \let\cyrh=х \let\cyrc=ц \let\cyrch=ч \let\cyrsh=ш
  \let\cyrshch=щ \let\cyrhrdsn=ъ \let\cyrsftsn=ь \let\cyryu=ю
  \let\cyrya=я
}
%    \end{macrocode}
% \end{macro}



%
%\subsection{Compatibility with older versions}
%
%
%    This is for compatibility with older Bulgarian packages and support
%    for \babel.
%
%    \begin{macrocode}
\DeclareRobustCommand{\No}{%
    \ifmmode{\nfss@text{\textnumero}}\else\textnumero\fi}
%    \end{macrocode}
%
%\subsection{Finish}
%
%
%    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 \texttt{@}
%    to its original value.
%
%    \begin{macrocode}
\ldf@finish{bulgarian}
%&lt;/code&gt;
%    \end{macrocode}
%
% \Finale
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote \"    Hash (number) \#
%%   Dollar        \$     Percent      \%    Ampersand     \&amp;
%%   Acute accent  \'     Left paren   \(    Right paren   \)
%%   Asterisk      \*     Plus         \+    Comma         \,
%%   Minus         \-     Point        \.    Solidus       \/
%%   Colon         \:     Semicolon    \;    Less than     \&lt;
%%   Equals        \=     Greater than \&gt;    Question mark \?
%%   Commercial at \@     Left bracket \[    Backslash     \\
%%   Right bracket \]     Circumflex   \^    Underscore    \_
%%   Grave accent  \`     Left brace   \{    Vertical bar  \|
%%   Right brace   \}     Tilde        \~}
%%
\endinput




% А\or
% Б\or
% В\or
% Г\or
% Д\or
% Е\or
% Ж\or
% З\or
% И\or
% Й\or
% К\or
% Л\or
% М\or
% Н\or
% О\or
% П\or
% Р\or
% С\or
% Т\or
% У\or
% Ф\or
% Х\or
% Ц\or
% Ч\or
% Ш\or
% Щ\or
% Ъ\or
% Ь\or
% Ю\or
% Я\or
%
% а\or
% б\or
% в\or
% г\or
% д\or
% е\or
% ж\or
% з\or
% и\or
% й\or
% к\or
% л\or
% м\or
% н\or
% о\or
% п\or
% р\or
% с\or
% т\or
% у\or
% ф\or
% х\or
% ц\or
% ч\or
% ш\or
% щ\or
% ъ\or
% ь\or
% ю\or
% я\or

\let\CYRA=А
\let\CYRB=Б
\let\CYRV=В
\let\CYRG=Г
\let\CYRD=Д
\let\CYRE=Е
\let\CYRZH=Ж
\let\CYRZ=З
\let\CYRI=И
\let\CYRISHRT=Й
\let\CYRK=К
\let\CYRL=Л
\let\CYRM=М
\let\CYRN=Н
\let\CYRO=О
\let\CYRP=П
\let\CYRR=Р
\let\CYRS=С
\let\CYRT=Т
\let\CYRU=У
\let\CYRF=Ф
\let\CYRH=Х
\let\CYRC=Ц
\let\CYRCH=Ч
\let\CYRSH=Ш
\let\CYRSHCH=Щ
\let\CYRHRDSN=Ъ
\let\CYRSFTSN=Ь
\let\CYRYU=Ю
\let\CYRYA=Я

\let\cyra=а
\let\cyrb=б
\let\cyrv=в
\let\cyrg=г
\let\cyrd=д
\let\cyre=е
\let\cyrzh=ж
\let\cyrz=з
\let\cyri=и
\let\cyrishrt=й
\let\cyrk=к
\let\cyrl=л
\let\cyrm=м
\let\cyrn=н
\let\cyro=о
\let\cyrp=п
\let\cyrr=р
\let\cyrs=с
\let\cyrt=т
\let\cyru=у
\let\cyrf=ф
\let\cyrh=х
\let\cyrc=ц
\let\cyrch=ч
\let\cyrsh=ш
\let\cyrshch=щ
\let\cyrhrdsn=ъ
\let\cyrsftsn=ь
\let\cyryu=ю
\let\cyrya=я
</pre></body></html>