\documentclass[12pt,a4paper,twosided]{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc} % temporary to make MakeUppercase work.
%\usepackage[english,bulgarian]{babel}
\usepackage[english,bulgarian]{babel}
\usepackage{mathptm}
\def\№{\Romannumeral}


\usepackage[bulgarian]{varioref}  % my modified varioref.sty 
                                  % waiting for the author of
                                  % varioref.sty to release this officially.
                                  % DO NOT DISTRIBUTE!

\title{Notes on Bulgarian typesetting in \LaTeX }
\author{Georgi Boshnakov}


\begin{document}

% \selectlanguage{bulgarian}

% \selectlanguage{english}

%%% "`abvg"'
%%% 
%%% \shorthandoff{"}
%%% 
%%% "`abvg"'
%%% 
%%% \shorthandon{"}
%%% 
%%% "№
%%% 
%%% 
%%% 
%%% \foreignlanguage{english}{``This is an English phrase.''}

%\enumBul

% \makeatletter
% \@Alph3, \@alph3

% \enumEng 

% \@Alph3, \@alph3

% \enumBul \@Alph3, \@alph3

% \makeatother


%%% \latintext
%%% 
%%% \textcyrillic{АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ}
%%% 
%%% \cyrillictext
%%% 
%%% \textlatin{abcdefghijklmnop}
%%% 
%%% \Bulgarian bg: ``adfafdadfafdsaf'' a'  b'
%%% 
%%% {\English eng1: ``adfafdadfafdsaf'' a'  b'}
%%% 
%%% {\selectlanguage{english} eng2: ``adfafdadfafdsaf'' a'  b'}
%%% 
%%% \selectbglanguage
%%% 
%%% 
%%% % \selectenglanguage


\maketitle

\tableofcontents

\section{Introduction} \label{sec:intro}


This document shows some features specific to the Bulgarian typesetting with babel.
The text is mainly English but the main language of the document, as far as \LaTeX{} is
concerned, is Bulgarian. This is possible because the encoding T2A  contains the latin
characters. On the other hand, the effect is that English hyphenation is not turned on and
therefore English words are not hyphenated or, if they are, they may be wrongly hyphenated. 
I have done this deliberately to emphasise that it is a good practice to change explicitly
the language.

This document was written initially for my package \texttt{bulgaria} developed in 1994-1996 to
support Bulgarian language in the then new version of \LaTeX. Since at the time the encoding
systems in general where in transition and because there was no standard for cyrillic ones I
assembled some fonts to support the MIK encoding (the prevalent encoding at the time in
Bulgaria, its origins are in DOS but it was supported in Windows as well, not by Microsoft
though). This allowed me to introduce a fully working implementation only a few months after
\LaTeX2e{} became the official \LaTeX{} version.

I later modified this to work with the Babel system the most important change being the
switch to the use of standard fonts and encodings. 
I handed this to the Babel developer Johannes Braams who is currently maintaining it. 


Prompted by some enquiries, I released the hyphenation stuff separately in may 2006.  It can
be found in the \texttt{language} subdirectory on CTAN or on my web page. 

% Note that currently the MikTeX suite replaces my hyphenation patterns (available as part of
% the babel package) with different ones which seem not to work.  So, I release my hyphenation
% files separately as well. 


Comments and suggestions are welcome. 
I do not give my email address here (because of the spamming curse) but you can easily find
me with a search engine. 
I will maintain the hyphenation and, if there is
demand, release a new set of patterns to support the more stylish traditional hyphenation
(the current patterns are the simplified ones, born in the computer age).


\section{Language and encoding} \label{sec:langenc}



There are still many encoding systems around, you need to tell \LaTeX{} which one you use.
For example, 
\begin{verbatim}
    \usepackage[cp1251]{inputenc}
\end{verbatim}
specifies the cyrillic encoding typically used in Windows. 
This line should be one of the first few lines after the \verb+\documentclass+ declaration.

The input encoding is completely independent of the internal encoding used by 
\LaTeX. You generally do not need to be concerned with it but for completeness here is the
command that specifies the internal (cyrillic) encoding \texttt{T2A}:
\begin{verbatim}
    \usepackage[T2A]{fontenc}
\end{verbatim}
This should not be needed but see the section about uppercase/lowercase below.

To change language you may use the babel assorment of commands, say 
\begin{verbatim}
   \selectlanguage{english} 
   \selectlanguage{bulgarian}
\end{verbatim}
see the user guide of Babel for details.
There are useful shorthands like 
\verb+\Bul+,
\verb+\Bg+,
\verb+\Eng+,
\verb+\latintext+,
and
\verb+\cyrillictext+.



\section{Alphabet} \label{sec:alphabet}



\subsection{Entering cyrillic letters}

The best way to enter Bulgarian text is to type it in some of the standard encodings
and leave \LaTeX\ to struggle with the conversion work (it knows most of the cyrillic
encodings).  To tell \LaTeX{} the input encoding, put near the beginning of your document a
line like
\begin{center}
\verb+\usepackage[utf8]{inputenc}+
\end{center}
if you are in the modern age and/or Linux,
or
\begin{center}
\verb+\usepackage[MIK]{inputenc}+
\end{center}
if you prefer ``classic DOS'' and the MIK encoding,
or
\begin{center}
\verb+\usepackage[cp1251]{inputenc}+
\end{center}
if you do not know what I am talking about and are on a Windows system.

This command is usually placed write after the \verb+\documentclass+ command.

If you need to enter only a couple of words you may also use commands like \verb+\cyra+,
\verb+CYRA+, \verb+\cyryu+, \verb+\CYRYU+. The number sign can be obtained by \verb+\No+ or
\verb+\textnumero+.

For example, \verb+\CYRA\CYRB\CYRV, \cyra\cyrb\cyrv+ produces
\begin{center}
\CYRA\CYRB\CYRV, \cyra\cyrb\cyrv
\end{center}

Accents in Bulgarian are used very rarely. This is done only to designate where the stress
falls in certain special circumstances (mainly to avoid confusion). For example, \verb+\`{и}+
gives \`{и}. This is unambigously a pronoun which if written without the accent may
occasionally be confused with the conjunction и (Bulgarian for ``and''). 

Warning: the shorter \verb+\`и+ works in all encodings except utf8. It is prudent to always
add the braces to avoid irritation if you decide to switch to utf8. 

% \"е


\subsection{Changing letter case (Uppercase/Lowercase)}

Use the \LaTeX{} commands \verb+\MakeLowercase+ and \verb+\MakeUppercase+ to change case of a
piece of text. For example, 

\verb+\MakeLowercase{АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ №}+

\noindent
gives

\MakeLowercase{АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ №}  

\noindent
(All letters should change to lowercase, if MakeLowercase works properly.)


\noindent
Similarly

\verb+\MakeUppercase{абвгдежзийклмнопрстуфхцчшщъыьэюя №}+

\noindent
gives

\MakeUppercase{абвгдежзийклмнопрстуфхцчшщъыьэюя №}

\noindent
% (All letters should change to uppercase, if MakeUppercase works properly.)

Note that the symbol № is unchanged by both commands since it is not a regular letter. 

If the above commands do not change the case properly, then this should be  rectified by 
including the command  \verb+\usepackage[T2A]{fontenc}+ in the preamble of your document
(this command should not be needed as T2A is the default encoding, a bug may have crawled in
somehow). If you have the \verb+.tex+ source of this file you may wish to comment out the 
\verb+usepackage+ command for package \verb+fontenc+ and compile the file to see the
difference, if any.


\subsection{The symbol №}

The symbol № is not particularly important but it is used occasionally, e.g.,

№\,1, №\,20,  №№\,1--5.

The Bulgarian keyboard has a key №. The commands 
\verb+\textnumero+ and \verb+\No+ produce № as well.


  \begin{table}  \label{table:No}
\centering
\begin{tabular}{cc}
\LaTeX{} source  & typeset output  \\ \hline
\verb+\textnumero\,3+ & \textnumero\,3 \\
\verb+\No\,3+          & \No\,3         \\
\verb+№\,3+            & №\,3 
\end{tabular}

  \end{table}



% \CYRA\CYRB\CYRV, \cyra\cyrb\cyrv


\subsection{Roman numbers}

In Bulgarian texts, uppercase Roman numbers are often used for ordinal
numbers. Most of them can be entered via the Bulgarian keyboard: the letters I and V are
available precisely for that purpose, M and C are the same in the cyrillic alphabet, but L is
missing. This does not matter much in the case of a computer keyboard. Even so,   I prefer to
redefine the I and V keys for more important tasks and leave the computer render a number in
Roman form, see also the comments in section~{sec:bugs}. 

The command \verb+\Romannumeral+ (with shorthand \verb+\№+ defined in the preamble of this
file) is provided for capitalised Roman numbers, e.g.: 
\verb+\№1+, 
\verb+\№8+, 
\verb+\№26+, 
\verb+\№{26}+,
give
\№1, \№8, \№26, and \№{26},
respectively. This example shows also that arguments with 2 or more decimal digits have to be
put in braces.


\subsection{Quoting styles}

The quotation marks in texts typeset in Bulgarian traditionally look like "`this"'. 
This style and the quotes themselves have been borrowed from the German language.

To get traditional Bulgarian style quotes enclose the text in \verb+"`+ and \verb+"'+. 
To get the French style quotes use \verb+"<+ and \verb+">+ instead. For example,

\begin{verbatim}
   ``English style quotes'' \par
   "`текст в традиционните за български текстове кавички"' \par
   "<алтернативни кавички, срещани предимно в по-стари текстове">
\end{verbatim}

\noindent
gives
% \selectlanguage{bulgarian}

\bigskip{}

   ``English style quotes'' \par
   "`текст в традиционните за български текстове кавички"' \par
   "<алтернативни кавички, срещани предимно в по-стари текстове">

% \selectlanguage{english}

\bigskip

Note that in the pre-babel \verb+bulgarian.sty+  quotes in Bulgarian texts were typeset
automatically in the traditional Bulgarian style.


\subsection{Dates}

The command \verb+\today+ produces the current date, e.g. today is \today.

In the traditional format for dates in Bulgaria uppercased roman numbers are used for the
months, e.g. today is \todayRoman.

\begin{center}
  \begin{tabular}{cc}
\LaTeX{} source  & typeset output  \\ \hline
\verb+\today+      & \today 	  \\  
\verb+\todayRoman+ & \todayRoman 
  \end{tabular}
\end{center}



\section{Hyphenation} \label{sec:hyph}


When you choose a language for \emph{babel}, \LaTeX{} hyphenates the text
according to the hyphenation rules of that language.
So, normally you do not need to do anything more to get proper hyphenation.

If your Bulgarian text does not get hyphenated, then you need to tell
the \TeX{} system to load Bulgarian hyphenation rules. The details are
system dependent but not complicated, see the documentation of your
\TeX{} distribution for details.

For example, if you are using MikTeX, start its \emph{Settings}
utility (known also as \emph{MikTeX options}, click the
\emph{Language} tab, tick \emph{bulgarian}, and click OK. MikTeX will
tell you that it needs to regenerate the formats, let it do it.  That
is it. Process a document to see that hyphenation works.

If you find words that do not hyphenate properly, then send me an email.











\section{Enumeration} \label{sec:enum}



Alphabetic enumeration is usually done with the Bulgarian alphabet but latin enumeration is
used as well.  Besides the alphabet, the style of the enumeration is somewhat different from
the English one.

We provide facilities for both cyrillic and latin enumeration. By default, the cyrillic one
is switched on by commands changing the language to Bulgarian. The declarations
\verb+\alphEng+ and \verb+\alphBul+ may be used to switch to and from latin enumeration, if
desired.

Note that the cyrillic enumeration here simply uses cyrillic letters wherever the standard
\LaTeX\ enumeration style would produce alphabetic enumeration.  This is definitely not
satisfactory and a fuller implementation might change other details but this is better left
to document classes.


The letters й, ъ, and ь are not used for enumeration and therefore omitted. Note that the
cyrillic letters э and ы are not part of the Bulgarian alphabet anyway.

\begin{enumerate}   \label{enum:1}
	\item a

	\begin{enumerate}
		\item aa
		\begin{enumerate}
			\item aaa
			\begin{enumerate}
				\item aaaa
	
				\item bbbb

				\item cccc

				\item dddd

			\end{enumerate}
	
			\item bbb

		\end{enumerate}

		\item bb

		\item cc

		\item dd

	\end{enumerate}

	\item b

\end{enumerate}


The following enumeration is preceded by the command
\verb+\enumEng+.

\enumEng 

\begin{enumerate}  \label{enum:2}
	\item a
	\begin{enumerate}
		\item aaaaaaa
		\begin{enumerate}
			\item aaaaaaa
			\begin{enumerate}
				\item aaaaaaa
	
				\item bbbbbbb

				\item cccccc

			\end{enumerate}
	
			\item bbbbbbb

			\item cccccc

		\end{enumerate}


	\end{enumerate}

	\item b

\end{enumerate}

\section{Support for the varioref package}


The package \texttt{varioref} allows for producing cross-references which look natural and
generally do not require manual intervention when the context changes. Support for Bulgarian
should be available with the next release of \LaTeX{}. This file has been produced with a
draft version of the package.

The table below is an illustration. Notice that the page reference command is the same in all cases
but the printed text changes depending on its relative distance from the reference point. 
Also, references to the current page and the facing page are automatically varied to some
extent.

\begin{center}
  
\begin{tabular}{l|l}
command & typeset output  \\  \hline
\verb+\vpageref{sec:intro}+    & \vpageref{sec:intro}            \\
\verb+\vpageref{enum:1}+       & \vpageref{enum:2}      \\
\verb+\vpageref{enum:2}+       & \vpageref{enum:2}      \\
\verb+\vpageref{table:No}+     & \vpageref{table:No} 
  
\end{tabular}
\end{center}

It is instructive to see what output would have produced if the above table turned up on the
following page. The table on the next page is generated by the same \LaTeX{} source as the
table above. There is a \verb+\newpage+ command after this paragraph to ensure that the two
tables are on different pages.


\newpage

\begin{center}
  
\begin{tabular}{l|l}
command & typeset output  \\  \hline
\verb+\vpageref{sec:intro}+    & \vpageref{sec:intro}            \\
\verb+\vpageref{enum:1}+       & \vpageref{enum:2}      \\
\verb+\vpageref{enum:2}+       & \vpageref{enum:2}      \\
\verb+\vpageref{table:No}+     & \vpageref{table:No} 
  
\end{tabular}
\end{center}



% Some text follows to  illustrate the usage of the commands in the
% \texttt{varioref}. 
% This paragraph is repeated at several places in this document, its text
% source is exactly the same but the output depends on the relative position of the referenced
% pages. Some silly page references follow. The introduction begins  
% \vpageref{sec:intro}, 
% the enumeration  \vpageref{enum:1} illustrates the default enumeration labels when
% Bulgarian is active while the enumeration \vpageref{enum:2}
% shows an alternative. 
% The table \vpageref{table:No} shows several ways to typeset \No.
% The especially dull introduction starts \vpageref{sec:intro} 
% and if this sentence is on the same page as the beginning of this paragraph the wording of
% the reference to it may be slightly different.


% Some text follows to  illustrate the usage of the commands in the
% \texttt{varioref}. 
% This paragraph is repeated at several places in this document, its text
% source is exactly the same but the output depends on the relative position of the referenced
% pages. Some silly page references follow. The introduction begins  
% \vpageref{sec:intro}, 
% the enumeration  \vpageref{enum:1} illustrates the default enumeration labels when
% Bulgarian is active while the enumeration \vpageref{enum:2}
% shows an alternative. 
% The table \vpageref{table:No} shows several ways to typeset \No.
% The especially dull introduction starts \vpageref{sec:intro} 
% and if this sentence is on the same page as the beginning of this paragraph the wording of
% the reference to it may be slightly different.
% 
% Some text follows to  illustrate the usage of the commands in the
% \texttt{varioref}. 
% This paragraph is repeated at several places in this document, its text
% source is exactly the same but the output depends on the relative position of the referenced
% pages. Some silly page references follow. The introduction begins  
% \vpageref{sec:intro}, 
% the enumeration  \vpageref{enum:1} illustrates the default enumeration labels when
% Bulgarian is active while the enumeration \vpageref{enum:2}
% shows an alternative. 
% The table \vpageref{table:No} shows several ways to typeset \No.
% The especially dull introduction starts \vpageref{sec:intro} 
% and if this sentence is on the same page as the beginning of this paragraph the wording of
% the reference to it may be slightly different.

\section{Reporting bugs and requesting features} \label{sec:bugs}

Please email me bug reports and requests for features, visit my web page at the
University of Manchester for further information.

I am using Emacs for typesetting documents. Emacs~22 has good support for essentially all
writing systems in the world. AucTeX is an amazing Emacs package which makes an excellent
environment for writing  LaTeX (and other ``dialects'' of TeX) documents). 
Another Emacs package, ESS (Emacs speaks statistics), integrates Emacs smoothly with some of
the major statistical systems. 

If you are using Emacs but have not considered AucTeX yet, do it!
If you do computations with systems such as R, S-plus or SAS, consider ESS.

If you are not an Emacs user you may consider becoming one. Together with the above tools it
may become your basic working environment. Be prepared though for a period of familiarisation
with the idiosyncracies of Emacs, it will help if you have a friend with some experience with
it.   

 


\end{document}





% \edef\myNo{\textnumero}

% \expandafter\meaning\csname T2A\endcsname

% \expandafter\meaning\csname T2A-cmd\endcsname

% \meaning\myNo

% \myNo: \csname \myNo \endcsname

%\selectlanguage{bulgarian}
% \labelenumii  
% \theenumii

% \meaning\textnumero

% \meaning\No

% \csname TeX \endcsname


% \Romannumeral  7

% \expandafter a\csname Romannumeral \endcsname 7

% \csname №\endcsname 

% \def\proba#1{\char#1}

% \proba 88, \proba{88}

% a: \expandafter\string\csname\proba157 \endcsname

% char65:\ \ \expandafter\string\csname \char65 \endcsname

% char157:   \expandafter\string\csname \char157 \endcsname

% char cyra:   \expandafter\string\expandafter\csname \cyra \endcsname

% \def\aaaa{aaaa}

% aaaa: \expandafter\string\csname \aaaa \endcsname

% \meaning\cyrzh

\makeatletter

\meaning\roman

\meaning\alph
 
\meaning\verbatim@font

\meaning\normalfont

\makeatother

\meaning\bulgarianhyphenmins

\meaning\englishhyphenmins

cyr. enc: \cyrillicencoding

\meaning\inputencoding

\meaning\frac

\expandafter\string\csname \the\CYRYA \endcsname

\begin{verbatim}

This is verbatim text. It contains both latin and cyrillic letters.
АБВГД ЕЖЗИЙ КЛМНОП РСТУФХЦ ЧШЩЪЫ ЬЭЮЯ

\end{verbatim}


