%
% Copyright (C) 2010-2019 Javier Bezos http://www.texnia.com
%
% This file may be distributed and/or modified under the conditions of
% the MIT License. A version can be found at the end of this file.
%

\documentclass{article}

\author{Javier Bezos}
\title{\textsf{babeltools}\\%
\Large Fixing (some) \textsf{babel} annoyances}

\begin{document}

\maketitle

\begin{center}
\fbox{\textbf{This package is deprecated. Use babel 3.9 and later instead.}}
\end{center}

The \textsf{babel} package introduces some changes in the \LaTeX{}
kernel which are not strictly necessary (perhaps just convenient), but
have some unwanted side-effects.  Oddly enough, most of these changes
cannot be disabled, with a few exceptions (eg, \texttt{activeacute}
and \texttt{activegrave}, but note there are not \texttt{activecaret}
or \texttt{activetilde}). 

With \textsf{babeltools} you can modify the \textsf{babel} behaviour
by means of a set of package options, with a few macros serving as
tools for specific purposes.  This package must be loaded
\textbf{before} \textsf{babel}.

\section{Package options}

\begin{description}
\item[shorthands=off] The shorthands mechanism is turned off.
As some languages use this mechanism for tools not available
otherwise, a macro \verb|\babelshorthand| is defined, which allows 
using them; see below. 

\item[shortands=...]  The shorthands mechanism is on, but the only
shorthands activated are those given, like, eg:
\begin{verbatim}
\usepackage[shorthands=:;!?]{babeltools}
\end{verbatim} 

If \verb|'| is included, \texttt{activeacute} is passed to
\textsf{babel}; if \verb|`| is included, \texttt{activegrave} is
passed.  Active characters (like \verb|~|) should be preceded by
\verb|\string| (otherwise they will be expanded by \LaTeX{} before
they are passed to the package and therefore they will not be
recognized).

\item[adaptive] By default, all \textsf{babel} shorthands are active
and live from start to end of documents.  You can deactivate them by
hand with \verb|\shorthandoff|, but this is cumbersome and you cannot
use it ``just in case'' (if the character is not a shorthands an error
is raised, instead of ignoring silently the redundant setting).  That
means you have to accept a character like : is active in an English
document even if you need it for just a few quotations in French.  The
default engine may be replaced by a new one which adapts the
shorthands behaviour to the context in the following way:
\begin{enumerate}
\item In math mode, while still shorthands, they behave always like the
corresponding normal char.  Things like \verb|$a \mathrel{x'} b$|
work as expected.

\item When the language is switched, shorthands chars are made normal or
active, as appropriate.  Thus, \texttt{:} or \texttt{?}  are active only in
\texttt{french}.
\end{enumerate}

% This option is useful when there are, say, short quotations in French
% inside a German text or when there are whole chapter in either French
% or German.

\item[nocrossrefs] newlabel, ref and pageref are not redefined. You 
cannot use shorthands in labels.

\item[nocitations] nocite, bibcite and bibitem are not redefined. You 
cannot use shorthands in labels.

\item[langcaptions] Captions are redefined if possible so that an
intermediate macro \verb|\lang...name| is used, eg,
\verb|\germanchaptername|.  Somewhat experimental.

\item[noconfig] Config files are not loaded, so you can make sure your
document is not spoilt by an unexpected \texttt{.cfg} file.
\end{description}

Babel tweaks several packages for shorthands to be accepted.  At the
time of this writing they are \textsf{cite}, \textsf{natbib},
\textsf{varioref} and \textsf{hhline} (the latter for the colon).  If
you don't use shorthands, these redefinitions are unnecessary and
inconvenient.  If you give a list of shorthands and it doesn't include
\verb|:|, then \verb|hhline| is left untouched.  The other packages
are handled by \texttt{nocrossrefs} and \texttt{nocitations}, as
appropriate.

\section{Macros}

\begin{description}
\item[\ttfamily\string\babelshorthand] Use a shorthand, even with
\texttt{shorthands=off} or not listed in it, eg,
\verb|\babelshorthand{"u}| or \verb|\babelshorthand{:}|.  You can
conveniently define your own macros.
\end{description}

\section{Known limitations}

If a class loads \textsf{babel} with a language, you cannot use
\textsf{babeltools}.  However, if a class loads babel without loading
any language, you can use it.  Languages given in
\verb|\documentclass| work as expected (provided the class doesn't
load it, of course).

\end{document}

MIT License
-----------

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.