I am trying to typeset a multilingual document, namely in german and
bulgarian. As i need some latin special characters as {\l} and {\ss} and
as bulgarian is written with the cyrillic alphabet, i need to use both T1
and T2A as font encoding.
While this works fine with the CM-fonts, I am having trouble to use e.g.
Times as the standard font. If I use the mathptmx package, german text is
fine, but I get an error that this font doesn't support the T2A encoding
and the bulgarian text is typeset with the CM-font. If I use the cyrtimes
package, cyrillic and latin text are fine, but {\l} and {\ss} get typeset
as black boxes.
So I would like to be able to change the fonts when the language is
changed, so that german text gets typeset using the font from mathptmx
and bulgarian text using the font from cyrtimes. I looked already in the
babel documentation, but I didn't find a solution. Also font selection
(other than by packages) seems terribly unintuitive to me, so I would
welcome any suggestions.
Thank you in advance,
regards Matthias
Minimal example:
----- snip -----
\documentclass{article}
\usepackage[bulgarian,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
% only use one of the following
%\usepackage{mathptmx}
%\usepackage{cyrtimes}
\begin{document}
Deutscher Text mit Sonderzeichen: Ää, Öö, Üü, ß, {\l}, {\L}.
\foreignlanguage{bulgarian}{Български текст.}
\end{document}
----- snip -----
it's pretty bad that cyrtimes does that. i note that author hasn't
submitted it to ctan -- perhaps he knows it's not really adequate.
>Minimal example:
>----- snip -----
>\documentclass{article}
>\usepackage[bulgarian,ngerman]{babel}
>\usepackage[utf8]{inputenc}
>\usepackage[T2A,T1]{fontenc}
>% only use one of the following
>%\usepackage{mathptmx}
you will probably need to load them in the other order.
>%\usepackage{cyrtimes}
...
use the babel language switches to change font:
\addtocaptionsngerman{\fontfamily{ptm}\selectfont}
\addtocaptionsbulgarian{\fontfamily{cyrtimes}\selectfont}
note: i don't know what the cyrtimes family calls itself: replace that
"cyrtimes" with the family it uses. find that with
\documentclass{minimal}
\usepackage[T2A]{fontenc}
\usepackage{cyrtimes}
\begin{document}
\typeout{family is \csname f@family\endcsname}
\end{document}
it may be that cyrtimes also uses ptm as family name ... if so we need
to think again.
--
Robin Fairbairns, Cambridge
> While this works fine with the CM-fonts, I am having trouble to use e.g.
> Times as the standard font. If I use the mathptmx package, german text is
> fine, but I get an error that this font doesn't support the T2A encoding
> and the bulgarian text is typeset with the CM-font. If I use the cyrtimes
> package, cyrillic and latin text are fine, but {\l} and {\ss} get typeset
> as black boxes.
cyrtimes.sty comes from the Debian package scalable-cyrfonts-tex,
right? In that case, please report this as a bug. While the package
does nominally support T1 encoding, this support is very much broken
as you found out. Since T1 encoding (and OT1 and TS1) for the LW35
base fonts is already provided by the PSNFSS package, it would be best
if scalable-cyrfonts-tex would not provide metrics for these encodings
at all and use those from PSNFSS instead. See elow for how this can be
done.
> So I would like to be able to change the fonts when the language is
> changed, so that german text gets typeset using the font from mathptmx
> and bulgarian text using the font from cyrtimes. I looked already in the
> babel documentation, but I didn't find a solution. Also font selection
> (other than by packages) seems terribly unintuitive to me, so I would
> welcome any suggestions.
One simple solution would be to use mathptmx (uses fontfamily ptm) but
switch locally to fontfamily ftm, which is used by cyrtimes. The other
possibilities are to change T1 encoding for ftm or to provide T2A
encoding for ptm with the help of suitable fd files. I will use the
latter approach below. As short explanation: fd files provide a
mapping from LaTeX/NFSS font identifiers to TeX font metric files (or
other LaTeX/NFSS font identifiers). By changing this mapping, one can
alter LaTeX's behaviour. For example, one can tell LaTeX to use the
metrics (and fonts) from cyrtimes when a T2A encoded ptm is requested:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents}{t2aptm.fd}
\ProvidesFile{t2aptm.fd}
[2008/03/08 Font definitions for T2A/ptm.]
\DeclareFontFamily{T2A}{ptm}{}
\DeclareFontShape{T2A}{ptm}{m}{n}{
<-> ftmr6a
}{}
\DeclareFontShape{T2A}{ptm}{m}{sc}{
<-> ftmrc6a
}{}
\DeclareFontShape{T2A}{ptm}{m}{sl}{
<-> ftmro6a
}{}
\DeclareFontShape{T2A}{ptm}{m}{it}{
<-> ftmri6a
}{}
\DeclareFontShape{T2A}{ptm}{b}{n}{
<-> ftmb6a
}{}
\DeclareFontShape{T2A}{ptm}{b}{sc}{
<-> ftmbc6a
}{}
\DeclareFontShape{T2A}{ptm}{b}{sl}{
<-> ftmbo6a
}{}
\DeclareFontShape{T2A}{ptm}{b}{it}{
<-> ftmbi6a
}{}
\DeclareFontShape{T2A}{ptm}{bx}{n}{<->ssub * ptm/b/n}{}
\DeclareFontShape{T2A}{ptm}{bx}{sc}{<->ssub * ptm/b/sc}{}
\DeclareFontShape{T2A}{ptm}{bx}{sl}{<->ssub * ptm/b/sl}{}
\DeclareFontShape{T2A}{ptm}{bx}{it}{<->ssub * ptm/b/it}{}
\endinput
\end{filecontents}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[bulgarian,ngerman]{babel}
\usepackage[T2A,T1]{fontenc}
\usepackage{mathptmx}
\newcommand{\bulgarian}[1]{{%
\fontfamily{ftm}\selectfont
\foreignlanguage{bulgarian}{#1}}}
\begin{document}
Deutscher Text mit Sonderzeichen: Ää, Öö, Üü, ß, {\l}, {\L}.
\bulgarian{Български текст.}
\foreignlanguage{bulgarian}{Български текст.}
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
When run through LaTeX, the above file will produce a file t2aptm.fd
(compare that with t2aftm.fd installed in your system). In order to
use this permanently you could install this, for example, in
/usr/local/texmf/tex/latex/local.
cheerio
ralf
Yes, I didn't realize that it wasn't a standard package included in the
texlive distribution I'm using. I filed a bug report (#470387) which you
can access at:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=470387
> One simple solution would be to use mathptmx (uses fontfamily ptm) but
> switch locally to fontfamily ftm, which is used by cyrtimes.
Alright, I seem to understand a little better the magic of font-
selection... This works fine for the moment, so I guess I will stick with
it for now until I'm more experienced in modifying my LaTeX-
installation :)
Thanks for your help!
> it's pretty bad that cyrtimes does that. i note that author hasn't
> submitted it to ctan -- perhaps he knows it's not really adequate.
As Ralf noted in the other thread I forgot to mention that cyrtimes is
part of Debian's scalable-cyrfonts-tex package.
> use the babel language switches to change font:
>
> \addtocaptionsngerman{\fontfamily{ptm}\selectfont}
> \addtocaptionsbulgarian{\fontfamily{cyrtimes}\selectfont}
>
> note: i don't know what the cyrtimes family calls itself: replace that
> "cyrtimes" with the family it uses.
cyrtimes calls itself ftm, so there is no naming-conflict. I tried to add
these two lines to the preamble of my document, however this seems to be
the wrong place. I get the error-message "Undefined control sequence.
\addtocaptionsngerman {\fontfamily{ptm}\selectfont}". I like this
approach because I don't have to introduce another command (as with the
quickfix Ralph pointed out in the other thread) to the document. Where
would I have to put this?
Thanks,
Matthias
The correct form would be \addto\captions<language>{....}. However,
that does not work and I don't know why. It does work to use
\addto\extras<language> like this:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[bulgarian,ngerman]{babel}
\addto\extrasbulgarian{\fontfamily{ftm}\selectfont}
\usepackage[T2A,T1]{fontenc}
\usepackage{mathptmx}
\begin{document}
Deutscher Text mit Sonderzeichen: Ää, Öö, Üü, ß, {\l}, {\L}.
\foreignlanguage{bulgarian}{Български текст.}
\end{document}
This still produces
LaTeX Font Warning: Font shape `T2A/ptm/m/n' undefined
(Font) using `T2A/cmr/m/n' instead on input line 10.
but in the end T2A/ftm is used for the Bulgarian parts.
cheerio
ralf