1

This is a followup question on: ASCII text set in Greek script when using \usepackage[greek]{babel}

When we have a MWE like:

\documentclass[twoside]{book}

\usepackage{fontspec}
\usepackage[greek]{babel}
\usepackage{alphabeta}
\setmainfont{Libertinus Serif}

\renewcommand{\familydefault}{\sfdefault}

\begin{document}

{My Project }

{Δημιουργήθηκε από  Doxygen 1.8.19}

\end{document}

we get:

enter image description here

We see that here part of the second line is missing, we expected:

enter image description here

This result is obtained by commenting out the line: \renewcommand{\familydefault}{\sfdefault} so an easy solution would be to do this also in the production code, but I hesitate as this line has been added in 2013 and it is unknown why it is added (doxygen was not yet in git at that moment, so individual commits were nor registered).

To give a bit side information, it looks like that the following lines were added at the same moment as well:

\usepackage[T1]{fontenc}
\usepackage[scaled=.90]{helvet}
\usepackage{courier}
\usepackage{amssymb}
\usepackage{sectsty}
\renewcommand{\familydefault}{\sfdefault}
\allsectionsfont{%
  \fontseries{bc}\selectfont%
  \color{darkgray}%
}
  • any idea why such a line\renewcommand{\familydefault}{\sfdefault} could have been added?
  • any suggestions for improvement of this line \renewcommand{\familydefault}{\sfdefault} so the functionality remains but the side effect disappears?
3
  • Well the command changes the font to sans serif, and in this case to latin modern sans which has no greek. So you will have to decide if you want to use a sans serif font, and if yes which one ... Jun 10, 2020 at 12:36
  • I set the main font to Libertinus Sans but now the renew line still gives a problem, commenting that line helps also the line \usepackage[T1]{fontenc} is problematic but I didn't see a negative effect yet commenting it as well. As the code is generated is there a way to check what the main font is or do I have to set a variable that I can test?
    – albert
    Jun 10, 2020 at 12:59
  • For the testing on the font I created a boolean variable and test on it.
    – albert
    Jun 10, 2020 at 16:51

2 Answers 2

2

You seem to want a document with a sans serif font as default:

\documentclass[twoside]{book}

\usepackage{fontspec}
\usepackage[greek]{babel}
%\usepackage{alphabeta} % why?
\setmainfont{Libertinus Sans}

\begin{document}

My Project

Δημιουργήθηκε από  Doxygen 1.8.19

\end{document}

Use the font you'd like best, provided it supports Greek.

With your code you set the serif font to Libertinus Serif, but since you don't specify the sans serif font family, the redefinition of \familydefault to \sffamily will choose the default, that is, Latin Modern Sans, which doesn't support Greek.

I don't think that alphabeta is necessary.

enter image description here

4
  • The alphabeta is copied from the larger project, it is not necessary for the small example (honestly: I even don't know if it is necessary for the larger project). The question was mainly about the \renewcommand also seen the context of the other commands. The question that remains is, as noted in a comment with the question,: "As the code is generated is there a way to check what the main font is or do I have to set a variable that I can test?" (the problem regarding T1 I already solved).
    – albert
    Jun 10, 2020 at 14:42
  • 1
    @albert alphabeta does nothing at all with XeLaTeX.
    – egreg
    Jun 10, 2020 at 15:27
  • thanks for the explanation of alphabeta
    – albert
    Jun 10, 2020 at 15:29
  • For the testing on the font I created a boolean variable and test on it.
    – albert
    Jun 10, 2020 at 16:51
1

The Computer Modern Unicode fonts are clones of Knuth’s Computer Modern, like Latin Modern is, that contain Greek. So you could use

\setmainfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}

A good tip for solving bugs like this is to add \tracinglostchars=2 to the top of the file. Then TeX will tell you if the font you selected does not contain a character you’re using. By default, it silently logs a warning message to the .log file.

You must log in to answer this question.

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