2

I am using the libertine and libertinust1math packages, in conjunction with the book document class.

The preamble to my thesis is long (> 1400 lines) and includes dozens of packages in addition to the libertine and libertinust1math packages mentioned above.

I have a large number of bibliographic entries in my thesis, and I need to use several characters from European and Asian languages. What is the best way in which to obtain these characters, with the lowest probability of side effects resulting from the dozens of packages used in my thesis?

The following MWE, which contains only a small fraction of the packages I am using in my thesis, gives a list of the characters that I need. Most of them I have already found in kernel commands. However, a few -- marked below with arrows -- I am still looking for.

For those characters -- "D with stroke," "e with tail," "L with slash," and "l with slash" -- it appears that there are multiple ways of obtaining them. What method(s) are likely to have the fewest potential side effects?

\documentclass[oneside,11pt]{book}

\usepackage[semibold,tt=false]{libertine}
\usepackage{libertinust1math}
\usepackage[
  expansion = false ,
  tracking = smallcaps ,
  letterspace = 40 ,
  final
]{microtype}
\usepackage[font={sf,small},labelsep=quad,labelfont=sc]{caption}
\usepackage[subrefformat=parens]{subcaption}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage{siunitx}
\sisetup{%
  detect-family, detect-shape, detect-weight,
  product-units = power,
  list-final-separator = {, and },
  retain-explicit-plus,
  input-comparators = {<=>\approx\ge\geq\gg\le\leq\ll\sim\lesssim\gtrsim}
}

\begin{document}

\begin{table}[!h]
  \centering
  \begin{tabular}{rlcll}
    \toprule
    & \~{a} & \verb|\~{a}| & ``a with tilde on top'' & Portuguese, Vietnamese, ...\\
    & \'{c} & \verb|\'{c}| & ``c with acute accent'' & Polish, Croatian, ...\\
    & \c{c} & \verb|\c{c}| & ``c with cedilla'' & French, Catalan, Portuguese, Turkish, Turkmen, ...\\
    & \v{c} & \verb|\v{c}| & ``c with v on top'' & Czech, Croatian, Slovak, Slovene, Latvian, ...\\
    $\rightarrow$ & D & ? & ``D with stroke'' & Serbo-Croatian, Vietnamese, ...\\
    $\rightarrow$ & e & ? & ``e with tail'' & Polish, Lithuanian, ...\\
    $\rightarrow$ & L & ? & ``L with slash'' & Polish, ...\\
    $\rightarrow$ & l & ? & ``l with slash'' & Polish, ...\\
    & \^{o} & \verb|\^{o}| & ``o with circumflex'' & French, ...\\
    & \o & \verb|\o| & ``o with slash'' & Danish, Norwegian, Faroese, ...\\
    & \v{R} & \verb|\v{R}| & ``R with v on top'' & Czech, ...\\
    & \v{s} & \verb|\v{s}| & ``s with v on top'' & Czech, ...\\
    & \H{u} & \verb|\H{u}| & ``u with double acute accent'' & Hungarian, ...\\
    & \"{u} & \verb|\"{u}| & ``u with umlaut'' & German, Hungarian, Turkish, Turkmen, ...\\
    & \'{y} & \verb|\'{y}| & ``y with acute accent'' & Czech, Slovak, Turkmen, Icelandic, ...\\
    \bottomrule
  \end{tabular}
\end{table}

\end{document}

mwe

3
  • 1
    I guess if those packages don't mess up with font configurations, and if the font you are using has those glyphs, there are at least two ways to input those characteres: either using Unicode directly, changing the keyboard and/or copy-pasting, or using (La)TeX macros. In the first case, maybe you'd better compile with xelatex or lualatex. As to the other letters, if you used texstudio you'd just click left and find out: \l{} \DJ{} \dj{} \k{e}.
    – user9424
    Feb 8, 2021 at 21:59
  • 2
    you haven't said whether you are using luatex xetex or pdftex, certainly with the first two you don't need any packages other than fontspec and a font that has the characters, but even with pdftex they all seem standard (\l and \L are the slashed l \DJ is the D with stroke I am not sure which letter you mean by e with tail, which Unicode value do you want there? Feb 8, 2021 at 22:59
  • 1
    @DavidCarlisle Given it's needed for Polish, I assume that he's looking for ę (lower case e with ogonek), I thought all TeX-folks were amateur linguists.
    – Don Hosek
    Feb 9, 2021 at 4:36

2 Answers 2

5

You mention Asian characters in the title for which the situation is a bit different but all the examples in your table are Latin script characters available with standard latex commands and fonts

So in xelatex or lualatex you could use

\documentclass{article}

\begin{document}

\~{a} \'{c} \c{c} \v{c} \DJ{} \k{e} \L{} \l{} \^{o} \o{} \v{R} \v{s} \H{u} \"{u} \'{y} 

ã ć ç č Đ ę Ł ł ô ø Ř š ű ü ý

\end{document}

enter image description here

In pdflatex you (as almost always the case) need the T1 encoding for European latin scripts rather than the default OT1 otherwise the Ogonek and slashed D are not available, but as in lualatex you can type the characters directly or via the standard latex accent commands

\documentclass{article}

\usepackage[T1]{fontenc}

\begin{document}

\~{a} \'{c} \c{c} \v{c} \DJ{} \k{e} \L{} \l{} \^{o} \o{} \v{R} \v{s} \H{u} \"{u} \'{y} 

ã ć ç č Đ ę Ł ł ô ø Ř š ű ü ý

\end{document}

enter image description here

There is more you can do to tell LaTeX about the language in use to get correct hyphenation and other features but no packages are needed to define the commands used and only font selection is an issue.

2
  • In context, I think “Asian” means Vietnamese.
    – Davislor
    Feb 9, 2021 at 10:25
  • 1
    @Davislor aha. OK that would make sense. By the way I hope you don't mind me posting a second answer Your answer is of course much more complete and informative (I voted:-) but I wanted to say that in the character range in the question latex (on any engine) more or less "just works" especially if it is one-off names in a bibliography so you probably don't need a full language setup, just get the right letters. So I wanted to post an answer using a "trivial" example document. Feb 9, 2021 at 11:41
6

As of 2021, I’d say the format most likely to work with no problems is UTF-8 in NFC form. Fortunately, the vast majority of text you will encounter is already in this form. PDFTeX cannot support combining characters, Unicode engines don’t support anything but UTF-8 out of the box, and some support files have erroneously inserted a hyphen between a base character and its combining accents in XeTeX or LuaTeX. (The latter bug might have been fixed by the time you read this.) UTF-8 will work in some contexts where old-fashioned TeX commands will not, such as verbatim text.

The best way to wipe out technical debt to the 1980s is to use LuaLaTeX, Unicode and OpenType. If your publisher still requires you to use legacy 8-bit fonts in PDFTeX in 2021, you can do this:

\documentclass[polish,lithuanian,french,czech,vietnamese,english]{article}
\tracinglostchars=2 % Warn if a glyph is missing from the font!
\usepackage[T5, T1]{fontenc} % Plus whatever others you might need
\usepackage[utf8]{inputenc} % The default since 2018
\usepackage{babel}
\usepackage{libertinus}
\usepackage{substitutefont}
\usepackage[paperwidth=10cm]{geometry} %  Format the MWE for TeX.SX

% The Type-1 versions of Libertiine and Libertinus do not support Vietnamese,
% so we substitute Charter.
\substitutefont{T5}{\rmdefault}{mdbch}

\begin{document}
\foreignlanguage{polish}{Łódź,}
\foreignlanguage{lithuanian}{Panevėžys,}
\foreignlanguage{french}{Villefranche-sur-Saône,}
\foreignlanguage{czech}{Bohušovice nad Ohří}
and
\foreignlanguage{vietnamese}{Thủ Đức}
\end{document}

Libertinus/Charter sample

The “LaTeX Font Encodings Guide” can tell you which 8-bit legacy font encoding you need to load. Normally, changing to the right language is enough. In a few cases, you might need to define something like {\fontencoding{T1}\selectfont\.{\textsc{\i}}} to get İ.

PDFLaTeX can handle precomposed UTF-8 characters but not decomposed ones, so you will want to make sure your document is normalized to UTF-8 in NFC form. There is no longer any reason to prefer commands like \v{c} unless you find them more convenient to type.

You will also notice that switching languages enables hyphenation of words with accented characters.

If you can switch to LuaLaTeX, you are much better off using Unicode and modern fonts. Libertinus does have glyphs for Vietnamese, which were never converted to legacy 8-bit TeX but are available in the OpenType font. You will get a document that you can search and copy from. LuaLaTeX and XeLaTeX can also handle combining characters, unlike PDFLaTeX. You can also usually get away with omitting language tags for individual words in Latin, Greek and Cyrillic scripts.

\documentclass[polish,lithuanian,french,czech,vietnamese,english]{article}
\tracinglostchars=2 % Warn if a glyph is missing from the font!
\usepackage{babel}
\usepackage{libertinus}
\usepackage[paperwidth=10cm]{geometry} %  Format the MWE for TeX.SX

\begin{document}
\foreignlanguage{polish}{Łódź,}
\foreignlanguage{lithuanian}{Panevėžys,}
\foreignlanguage{french}{Villefranche-sur-Saône,}
\foreignlanguage{czech}{Bohušovice nad Ohří}
and
\foreignlanguage{vietnamese}{Thủ Đức}
\end{document}

Libertinus sample

Commands such as \v{c} will still work, if you want to use them.

For some languages, such as Dutch, Turkish or Bulgarian, you might need to enable OpenType language features to get the correct letter forms and ligatures. In this case, you would want to replace \usepackage{libertinus} with

\documentclass[turkish,english]{article}
\tracinglostchars=2 % Warn if a glyph is missing from the font!
\usepackage{babel}
\usepackage{libertinus}
\usepackage[paperwidth=10cm]{geometry} %  Format the MWE for TeX.SX

\usepackage{unicode-math}

\babelfont{rm}
          [Ligatures={Common,Discretionary,TeX}]{Libertinus Serif}
\babelfont{sf}
          [Ligatures={Common,Discretionary,TeX}]{Libertinus Sans}
\babelfont{tt}
          [Ligatures=TeX]{Libertinus Mono}
\setmathfont{Libertinus Math}

\begin{document}
\textsc{Peoria} and
\foreignlanguage{turkish}{\textsc{Türkiye}}.
\end{document}

Libertinus Serif sample

This correctly sets the Script= and Language= features of your OpenType font to the language you selected. Here, that sets the small caps form of i to I in English and İ in Turkish.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .