0

In my documents, I use Bitstream Charter (serif) as the main font. The the headings are typeset in Bitstream Vera Sans and code in Bitstream Vera Mono. The following is the code that I use to load them:

% This replaces all fonts with Bitstream Charter, Bitstream Vera Sans and
% Bitstream Vera Mono. Math will be rendered in Charter.
\RequirePackage[charter, greekuppercase=italicized]{mathdesign}
\RequirePackage{beramono}
\RequirePackage{berasans}

% Bold vectors.
\RequirePackage{isomath}
\renewcommand{\vec}{\vectorsym}
\newcommand{\tens}{\tensorsym}
\newcommand{\mat}{\matrixsym}

\ifluatex
\else
    \RequirePackage[T1]{fontenc}
    \RequirePackage[utf8]{inputenc}
\fi

A while ago I switched to LuaLaTeX, mainly because of the graph layout engine in TikZ.

My font selection knowledge in LaTeX is extremely thin, I have heard about things like fontspec and OTF fonts for LuaLaTeX. In principle this should allow me to use more fonts and even get different fonts into math mode such that I could use different fonts than the ones listed at the LaTeX math font survey.

Could my preamble be changed in some way that things are improved for LuaLaTeX or should I just keep it as-is?

Minimal Working Example

This is a minimal example showing off all the important points with the fonts. As mentioned in the comments, there was indeed a problem with the “ß” character. Turns out I did not create any German documents with LuaLaTeX but was only concerned with documents in English in the last years. This was easily fixed by adding fontenc and luainputenc`.

\documentclass[11pt, ngerman, fleqn, parskip=half]{scrartcl}

\usepackage{ifluatex}
\usepackage{babel}

\ifluatex
\else
    \usepackage[activate]{microtype}
\fi

\usepackage[charter, greekuppercase=italicized]{mathdesign}
\usepackage{beramono}
\usepackage{berasans}

\usepackage{isomath}
\renewcommand{\vec}{\vectorsym}
\newcommand{\tens}{\tensorsym}
\newcommand{\mat}{\matrixsym}
\newcommand{\four}[1]{\underline{\vec {#1}}}
\newcommand\setname[1]{\text{\bfseries\sffamily{#1}}}

\usepackage{amsmath}
\usepackage{amsthm}

% The following paragraph is what I had before, but the “ß” character did not
% work out. So this is now replaced by `luainputenc` paragraph below.

%\ifluatex
%\else
%    \usepackage[T1]{fontenc}
%    \usepackage[utf8]{inputenc}
%\fi

\usepackage[T1]{fontenc}
\usepackage[utf8]{luainputenc}

\begin{document}

Dies ist mein Minimalbeispiel. Es kommt auch mit nicht-ASCII Zeichen klar:

ae ä oe ö ue ü ss ß

rising á, falling, à, tilde ã, caret â

Außerdem kann ich Formeln nach ISO 80000-2 nutzen: Skalar $M$, Vektor $\vec M$,
Matrix $\mat M$, Tensor $\tens M$, Menge $\setname M$.

\end{document}

enter image description here

Second MWE

I have tried to get rid of T1 and the font packages but instead use fontspec:

\documentclass[11pt, ngerman, fleqn, parskip=half, DIV=9]{scrartcl}

\usepackage{ifluatex}
\usepackage{babel}

\ifluatex
\else
    \usepackage[activate]{microtype}
\fi

%\usepackage[charter, greekuppercase=italicized]{mathdesign}
%usepackage{beramono}
%usepackage{berasans}

\usepackage{fontspec}

\setmainfont{XCharter}
\setsansfont{Noto Sans}
\setmonofont{Noto Mono}
\setmathrm{XCharter}
\setboldmathrm{XCharter Bold}

\usepackage{isomath}
\renewcommand{\vec}{\vectorsym}
\newcommand{\tens}{\tensorsym}
\newcommand{\mat}{\matrixsym}
\newcommand{\four}[1]{\underline{\vec {#1}}}
\newcommand\setname[1]{\text{\bfseries\sffamily{#1}}}

\usepackage{amsmath}
\usepackage{amsthm}

\usepackage[utf8]{luainputenc}

\newcommand\pangramm{Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.}

\begin{document}

Dies ist mein Minimalbeispiel. Es kommt auch mit nicht-ASCII Zeichen klar:

ae ä oe ö ue ü ss ß

rising á, falling, à, tilde ã, caret â

Test der automatischen Silbentrennung:

grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen
grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen
grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen
grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen grüßen

Außerdem kann ich Formeln nach ISO 80000-2 nutzen: Skalar $M$ (= \emph M),
Vektor $\vec M$, Matrix $\mat M$, Tensor $\tens M$, Menge $\setname M$.

\[
    \int \mathcal D x = \prod_i \int_{-\infty}^{\infty} \mathrm d x_i \,.
\]

Serif: \pangramm

Serif Bold: \textbf{\pangramm}

Serif Italic: \textit{\pangramm}

Sans: \textsf{\pangramm}

Sans Bold: \textbf{\textsf{\pangramm}}

Sans Italic: \textit{\textsf{\pangramm}}

Mono: \texttt{\pangramm}

\end{document}

I don't have Bitstream Vera Sans and Mono installed, so I just used the Noto fonts.

This seems to support accents and also hyphenation:

enter image description here

However, the default math font (should be serif italic) looks like Computer Modern, although my \mathrm font is Bitstream Charter:

enter image description here

What would be missing to get the XCharter fully working in math mode? Would that automatically get Greek letters matching as well?

  • You can't use Bitstream Vera from TeXlive with LuaTeX because it only comes as Postscript fonts. You can download the TTF version from gnome.org/fonts – Henri Menke Sep 26 '17 at 7:28
  • Also »Could my preamble be ... improved« is an opinion-based question. Voting to close. – Henri Menke Sep 26 '17 at 7:29
  • Your snippets looks as if you never used some accents or non ascii chars. What happens if you write Grüße in your document? – Ulrike Fischer Sep 26 '17 at 7:31
  • 2
    Answers on questions about fonts really depend on detail. Post a MWE customised to your usage. – Keks Dose Sep 26 '17 at 8:37
  • 1
    It doesn't make much sense to switch to luatex and then to stick to T1-encoded fonts - while you can get the correct glyphs with luainputenc the hyphenation can be wrong as in luatex it assumes unicode. E.g. lualatex will not hyphenate grüßen in a german document. – Ulrike Fischer Sep 27 '17 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.