how to render PDF over latex of a greek translation (language 'el')

391 views
Skip to first unread message

Pieter Claeys

unread,
Sep 26, 2019, 11:16:55 AM9/26/19
to sphinx-users
Hi,
I'm stuck on trying to generate a PDF of a greek translation (language code 'el')

What I'm doing:
- "make latex"  -> produce .tex  file
- then, open with TexWorks and create pdf (or use pdflate command-line)

That doesn't work, and based on reading the documentation, I added to latex_elements in conf.py
latex_elements = {
'fontenc': r'\usepackage[LGR]{fontenc}',
'textgreek': r'\usepackage{textalpha,alphabeta}',

But still I'm stuck at

Package inputenc Error: Unicode character Α (U+0391)
(inputenc) not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type H <return> for immediate help.
 
...
 
l
.98 ...Απαιτήσεις συστήματος}

Which is caused by the line 98 in the .tex file:
\chapter{Απαιτήσεις συστήματος}


Anyone with experience with this?


The top of my .tex file is:

%% Generated by Sphinx.

\def\sphinxdocclass{report}

\documentclass[a4paper,10pt,greek]{sphinxmanual_customqaweb}

\ifdefined\pdfpxdimen

  \let\sphinxpxdimen\pdfpxdimen\else\newdimen\sphinxpxdimen

\fi \sphinxpxdimen=.75bp\relax


\PassOptionsToPackage{warn}{textcomp}

\usepackage[utf8]{inputenc}

\ifdefined\DeclareUnicodeCharacter

% support both utf8 and utf8x syntaxes

 \ifdefined\DeclareUnicodeCharacterAsOptional

   \def\sphinxDUC#1{\DeclareUnicodeCharacter{"#1}}

 \else

   \let\sphinxDUC\DeclareUnicodeCharacter

 \fi

 \sphinxDUC{00A0}{\nobreakspace}

 \sphinxDUC{2500}{\sphinxunichar{2500}}

 \sphinxDUC{2502}{\sphinxunichar{2502}}

 \sphinxDUC{2514}{\sphinxunichar{2514}}

 \sphinxDUC{251C}{\sphinxunichar{251C}}

 \sphinxDUC{2572}{\textbackslash}

\fi

\usepackage{cmap}

\usepackage[LGR]{fontenc}

\usepackage{amsmath,amssymb,amstext}

\usepackage{babel}

\usepackage{substitutefont}



\usepackage{times}

\expandafter\ifx\csname T@LGR\endcsname\relax

\else

% LGR was declared as font encoding

 \substitutefont{LGR}{\rmdefault}{cmr}

 \substitutefont{LGR}{\sfdefault}{cmss}

 \substitutefont{LGR}{\ttdefault}{cmtt}

\fi

\expandafter\ifx\csname T@X2\endcsname\relax

 \expandafter\ifx\csname T@T2A\endcsname\relax

 \else

 % T2A was declared as font encoding

   \substitutefont{T2A}{\rmdefault}{cmr}

   \substitutefont{T2A}{\sfdefault}{cmss}

   \substitutefont{T2A}{\ttdefault}{cmtt}

 \fi

\else

% X2 was declared as font encoding

 \substitutefont{X2}{\rmdefault}{cmr}

 \substitutefont{X2}{\sfdefault}{cmss}

 \substitutefont{X2}{\ttdefault}{cmtt}

\fi


\usepackage{textalpha,alphabeta}

\usepackage[Sonny]{fncychap}

\ChNameVar{\Large\normalfont\sffamily}

\ChTitleVar{\Large\normalfont\sffamily}

\usepackage{sphinx}


\fvset{fontsize=\small}

\usepackage{geometry}


% Include hyperref last.

\usepackage{hyperref}

% Fix anchor placement for figures with captions.

\usepackage{hypcap}% it must be loaded after hyperref.

% Set up styles of URL: it should be placed after hyperref.

\urlstyle{same}


\usepackage{sphinxmessages}

\setcounter{tocdepth}{1}




\title{QAWeb Enterprise User Guide}

\date{26 de Σεπτεμβρίου de 2019}

\release{}

\author{Barco}

\newcommand{\sphinxlogo}{\vbox{}}

\renewcommand{\releasename}{}

\makeindex

\begin{document}


\ifdefined\shorthandoff

 \ifnum\catcode`\=\string=\active\shorthandoff{=}\fi

 \ifnum\catcode`\"=\active\shorthandoff{"}\fi

\fi


\pagestyle{empty}

\sphinxmaketitle

\pagestyle{plain}

\sphinxtableofcontents

\pagestyle{normal}

\phantomsection\label{\detokenize{index::doc}}




\chapter{Απαιτήσεις συστήματος}

\label{\detokenize{system-requirements:system-requirements}}\label{\detokenize{system-requirements:requirements-system}}\label{\detokenize{system-requirements::doc}}





jfbu

unread,
Sep 26, 2019, 12:12:07 PM9/26/19
to sphinx...@googlegroups.com
Hi

Le 26/09/2019 à 17:16, Pieter Claeys a écrit :
> Hi,
> I'm stuck on trying to generate a PDF of a greek translation (language code 'el')
>
> What I'm doing:
> - "make latex"  -> produce .tex  file
> - then, open with TexWorks and create pdf (or use pdflate command-line)
>
> That doesn't work, and based on reading the documentation, I added to latex_elements in conf.py
>
> latex_elements = {
> 'fontenc': r'\usepackage[LGR]{fontenc}',
> 'textgreek': r'\usepackage{textalpha,alphabeta}',
>
>
> But still I'm stuck at
>
> |
> Packageinputenc Error:Unicodecharacter Α(U+0391)
> (inputenc)notsetup forusewithLaTeX.
>
> Seethe inputenc packagedocumentation forexplanation.
> TypeH <return>forimmediate help.
>  ...
>  
> l.98...Απαιτήσειςσυστήματος}
> |
>
> Which is caused by the line 98 in the .tex file:
> |
> \chapter{Απαιτήσειςσυστήματος}
> |
>
> *
> *
> Anyone with experience with this?
>
>
> The top of my .tex file is:
> |
>
> %%GeneratedbySphinx.
>
> \def\sphinxdocclass{report}
>
> \documentclass[a4paper,10pt,greek]{sphinxmanual_customqaweb}
>
> \ifdefined\pdfpxdimen
>
>   \let\sphinxpxdimen\pdfpxdimen\else\newdimen\sphinxpxdimen
>
> \fi\sphinxpxdimen=.75bp\relax
>
>
> \PassOptionsToPackage{warn}{textcomp}
>
> \usepackage[utf8]{inputenc}
>
> \ifdefined\DeclareUnicodeCharacter
>
> %support both utf8 andutf8x syntaxes
>
>  \ifdefined\DeclareUnicodeCharacterAsOptional
>
>    \def\sphinxDUC#1{\DeclareUnicodeCharacter{"#1}}
>
>  \else
>
>    \let\sphinxDUC\DeclareUnicodeCharacter
>
>  \fi
>
>  \sphinxDUC{00A0}{\nobreakspace}
>
>  \sphinxDUC{2500}{\sphinxunichar{2500}}
>
>  \sphinxDUC{2502}{\sphinxunichar{2502}}
>
>  \sphinxDUC{2514}{\sphinxunichar{2514}}
>
>  \sphinxDUC{251C}{\sphinxunichar{251C}}
>
>  \sphinxDUC{2572}{\textbackslash}
>
> \fi
>
> \usepackage{cmap}
>
> \usepackage[LGR]{fontenc}
>
> \usepackage{amsmath,amssymb,amstext}
>
> \usepackage{babel}
>
> \usepackage{substitutefont}
>
>
>
> \usepackage{times}
>
> \expandafter\ifx\csname T@LGR\endcsname\relax
>
> \else
>
> %LGR was declared asfont encoding
>
>  \substitutefont{LGR}{\rmdefault}{cmr}
>
>  \substitutefont{LGR}{\sfdefault}{cmss}
>
>  \substitutefont{LGR}{\ttdefault}{cmtt}
>
> \fi
>
> \expandafter\ifx\csname T@X2\endcsname\relax
>
>  \expandafter\ifx\csname T@T2A\endcsname\relax
>
>  \else
>
>  %T2A was declared asfont encoding
>
>    \substitutefont{T2A}{\rmdefault}{cmr}
>
>    \substitutefont{T2A}{\sfdefault}{cmss}
>
>    \substitutefont{T2A}{\ttdefault}{cmtt}
>
>  \fi
>
> \else
>
> %X2 was declared asfont encoding
>
>  \substitutefont{X2}{\rmdefault}{cmr}
>
>  \substitutefont{X2}{\sfdefault}{cmss}
>
>  \substitutefont{X2}{\ttdefault}{cmtt}
>
> \fi
>
>
> \usepackage{textalpha,alphabeta}
>
> \usepackage[Sonny]{fncychap}
>
> \ChNameVar{\Large\normalfont\sffamily}
>
> \ChTitleVar{\Large\normalfont\sffamily}
>
> \usepackage{sphinx}
>
>
> \fvset{fontsize=\small}
>
> \usepackage{geometry}
>
>
> %Includehyperref last.
>
> \usepackage{hyperref}
>
> %Fixanchor placement forfigures withcaptions.
>
> \usepackage{hypcap}%it must be loaded after hyperref.
>
> %Setup styles of URL:it should be placed after hyperref.
>
> \urlstyle{same}
>
>
> \usepackage{sphinxmessages}
>
> \setcounter{tocdepth}{1}
>
>
>
>
> \title{QAWebEnterpriseUserGuide}
>
> \date{26de Σεπτεμβρίουde 2019}
>
> \release{}
>
> \author{Barco}
>
> \newcommand{\sphinxlogo}{\vbox{}}
>
> \renewcommand{\releasename}{}
>
> \makeindex
>
> \begin{document}
>
>
> \ifdefined\shorthandoff
>
>  \ifnum\catcode`\=\string=\active\shorthandoff{=}\fi
>
>  \ifnum\catcode`\"=\active\shorthandoff{"}\fi
>
> \fi
>
>
> \pagestyle{empty}
>
> \sphinxmaketitle
>
> \pagestyle{plain}
>
> \sphinxtableofcontents
>
> \pagestyle{normal}
>
> \phantomsection\label{\detokenize{index::doc}}
>
>
>
>
> \chapter{Απαιτήσειςσυστήματος}
>
> \label{\detokenize{system-requirements:system-requirements}}\label{\detokenize{system-requirements:requirements-system}}\label{\detokenize{system-requirements::doc}}
>
> |
>
>
>
>


I tried a skeleton project containing only this index.rst

===============================
Welcome to FOO's documentation!
===============================

*********************
Απαιτήσεις συστήματος
*********************


and

language = 'el'
latex_elements = {
'fontenc': r'\usepackage[LGR]{fontenc}',
'textgreek': r'\usepackage{textalpha,alphabeta}',
}

and "make latexpdf" works for me and produces seemingly valid PDF.

Perhaps your LaTeX installation is old?
You seem to be using a custom class maybe this is related to the problem?


I am not familiar with typesetting Greek documents with LaTeX + \usepackage{babel}
and will check some docs later

From testing directly with LaTeX it seems simply using "greek" as
documentclass option should be enough in combination with babel. The
non-existing times font in Greek encoding is automatically
substituted.

By the way, if one only specifies language = 'el'
Sphinx mark-up leads to execution of \substitutefont
which causes a problem because \usepackage{substitutefont} is not
added explicitly to latex preamble until one explicitly
also specifies


'fontenc': r'\usepackage[LGR]{fontenc}',



The Sphinx documentation was only given in relation
to small Greek snippets in a doucment whose main language is another one.

Some revision/update might be needed for Greek as main language indeed.


Anyway, as I said your configuratin does seem to work for me with Sphinx 2.0 and
TeXLive 2019

Curious to know the cause of the problem

Jean-François



Pieter Claeys

unread,
Sep 26, 2019, 2:59:46 PM9/26/19
to sphinx...@googlegroups.com
Thanks for reply already.
- My customclass wasn't the problem (it was just a copy of the spinxmanual class with a slightly modified title. Now it crashes on \sphinxtmakeitle . Which would maybe indicate that other 'built-in' strings cause the issue as well.
- Using sphinx 2.1.2
- Building on Windows using MikTeX 2.9 (pdf latex version: This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7000 64-bit)
- the rst file is english; using sphinx-intl that fetches greek locale to build

I'll try to isolate the problem a bit more in a separate project.

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/qmio0d%2414g5%241%40blaine.gmane.org.

Pieter Claeys

unread,
Sep 26, 2019, 3:25:43 PM9/26/19
to sphinx-users
OK, right, I've trimmed it down even further.
I don't have perl installed so 'make latexpdf' isn't an option at the moment; I do two-step  'make latex' and then 'pdflatex <filename>.tex'

I've got the most basic setup now - see attached files
- an index.rst
- a conf.py
- a python requirements.txt

For me, pdflatex stops with the error at \sphinxmaketitle
Would be interesting to know if that builds on your machine... 


index.rst
conf.py
requirements.txt

jfbu

unread,
Sep 26, 2019, 6:24:12 PM9/26/19
to sphinx...@googlegroups.com
Hi, thanks for small project.

I don't seem to have issues with it at my locale:

greektest$ make latex
Sphinx v2.2.0 en cours d'exécution
Chargement des traductions [el]...fait
création du répertoire de sortie... fait
construction en cours [mo]:targets for 0 po files that are out of date
construction en cours[latex]: all documents
updating environment: [nouvelle configuration] 1 added, 0 changed, 0 removed
lecture des sources...[100%] index
recherche des fichiers périmésaucun résultat
pickling environment... fait
checking consistency... fait
processing greektest.tex... index
résolution des références...
fait
writing... fait
copying TeX support files... copie des fichiers de support Tex...
fait
compilation réussi.

Les fichiers LaTex se trouvent dans _build/latex.
Run 'make' in that directory to run these through (pdf)latex
(use `make latexpdf' here to do that automatically).


(the above uses French language for user interaction ; unfortunately
quite a few strings were badly translated by some contributor some
months ago -- see for example "compilation réussi" -- I have fixed
dozens of strings at transifex but this will have to wait next major release
for incorporation)

Then

greektest$ cd _build/latex/
latex$ pdflatex greektest
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex)
[.... lots of console output ...]
Package rerunfilecheck Warning: File `greektest.out' has changed.
(rerunfilecheck) Rerun to get outlines right
(rerunfilecheck) or use package `bookmark'.


LaTeX Font Warning: Some font shapes were not available, defaults substituted.


LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

)</usr/local/texlive/2019/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
</usr/local/texlive/2019/texmf-dist/fonts/type1/public/cbfonts/grmn1000.pfb></u
sr/local/texlive/2019/texmf-dist/fonts/type1/public/cbfonts/gsmn1440.pfb></usr/
local/texlive/2019/texmf-dist/fonts/type1/public/cbfonts/gsxi1728.pfb></usr/loc
al/texlive/2019/texmf-dist/fonts/type1/public/cbfonts/gsxn1000.pfb></usr/local/
texlive/2019/texmf-dist/fonts/type1/public/cbfonts/gsxn1200.pfb></usr/local/tex
live/2019/texmf-dist/fonts/type1/public/cbfonts/gsxn1728.pfb></usr/local/texliv
e/2019/texmf-dist/fonts/type1/public/cbfonts/gsxn2488.pfb>
Output written on greektest.pdf (5 pages, 85188 bytes).
Transcript written on greektest.log.


Thus no error (but an invitation to execute pdflatex again)

Your error with \sphinxmaketitle can come from a custom latex_documents docclass
see https://github.com/sphinx-doc/sphinx/pull/6683

Note: running pdflatex once is definitly not enough:
as LaTeX reports you need at least one additional runs.

A make.bat is provided that you will find in the latex build repertory

As you are on Windows it uses old Sphinx approach hence does *not* use
latexmk hence does not require Perl

I don't know the Windows syntax but on Linux it would be make all-pdf
in the LaTeX build repertory to get the PDF correctly done

I tried the same with TeXLive 2018 and it compiles the same.

I tried also with Sphinx 2.1.2 with same result.

I would need

1. greektest.tex

2. greektest.log after the failed pdflatex run

Ideally if you add manually the line to greektest.tex

\tracingmacros1

immediately after the line

\begin{document}

and execute

pdflatex --halt-on-error greektest.tex

the greektest.log file will contain important information to debug the problem.

Make sure you remove the latex build repertory first and do a clean make latex at root of project.

Best,

Jean-François

jfbu

unread,
Sep 26, 2019, 6:57:01 PM9/26/19
to sphinx...@googlegroups.com
Some additional remarks :


1. Sphinx does not support truly multilingual documents for latex output.

2. If you pass "el" as language which will translate as "greek" LaTeX
documentclass option, the ENTIRE document MUST be GREEK.
Any Latin string such as "aaaa" will look like "αααα" in PDF.
This is caused by the fact that babel with "greek" will make LGR
the main font encoding. There is NO WAY with pdflatex to get ascii "a"
to automatically trigger back T1 font encoding. LaTeX was conceived
as requiring user extra manual markup like \fontencoding{T1}\selectfont

And one sees "γρεεκτεστ" in PDF output which originates in "greektest"
for the project title.

(this is despite your \usepackage[LGR,T1]{fontenc}. The "greek" option
will make LGR main encoding anyhow)

3. This problem disappears if the LaTeX document uses "english" as option.
Then Sphinx latex writer has a mechanism to handle with the help of
subsitutefont package Greek letters. If Greek letters are 90% of document
it will still mostly work.

All of the above is with traditional pdflatex.


I suggest you try rather

latex_engine = "xelatex"

and then do NOT customize "fontenc" key at all.

Recent Sphinx uses then GNU FreeFont which supports Greek script.

It works well at my locale : Latin words show up as Latin in PDF output,
and Greek is rendered correctly including Table of contents etc...

In fact I don't think there is really Sphinx support for PDF
(via make latex and then pdflatex)
together with Greek as main document language.

The only way is to use xelatex or lualatex.

Except if EVERYTHING is translated into Greek, OR the language option
of the LaTeX file is NOT Greek. I know this is weird.

Best

Jean-François



Pieter Claeys

unread,
Sep 28, 2019, 10:52:07 AM9/28/19
to sphinx-users

Hi Jean-François,
many thanks for your support sharing this information. I never imagined having to dive so deep into this; all I wanted was a Greek translation ;-) 

Goo news: So, I have almost nailed it!

About Windows vs Linux
When indeed I tried the same small project (with pdflatex engine, language=el, and #'fontenc': r'\usepackage[LGR,X2,T1]{fontenc}' on a fresh Ubuntu, it works. Just had to do some trial-and-error with installing different texlive packages, then it works. Lesson learned: Don't use Windows / MikTex...

About pdflatex with greek
I then then got quite a bit further, only  remaining problem was that pdflatex erorred on the copyright © and trademark ™ characters. Deleting those built the document, and indeed, as you mentioned, every roman character was converted to Greek alphabet. That was already fine for me, I just needed some Greek translation :-)

A venture into xelatex
Indeed it works out of the box (at least on Linux) when latex_engine=xelatex. So I will switch to building everything (all languages) with xelatex (please warn me if that's a bad idea). I have some Chinese, Korean and Japanse translations on the longer term roadmap, so xelatex hopefully deals with that as well.

Note: Actually I tried xelatex before, but got stuck on an error:
Package polyglossia Error: The current roman font does not contain the Greek (polyglossia) Please define \greekfont with \newfontfamily. \sphinxmaketitle

Another half a day later I now see that this was caused by a line that I added to sphinxmanual.cls (named sphinxmanual_customqaweb.cls). I add an extra image on the title page, with this line:
{\sphinxincludegraphics{celabel_1639.png}\par}
... which cases the polyglossia problem on xelatex ,   not on pdflatex.
I still don't understand why this breaks things ; it's almost identical as the \sphinxlogo  method
    \begin{flushright}%
      \sphinxlogo
      \py@HeaderFamily
      {\Huge \@title \par}
      {\itshape\LARGE \py@release\releaseinfo \par}
      \vfill
      {\LARGE
        \begin{tabular}[t]{c}
          \@author
        \end{tabular}\kern-\tabcolsep
        \par}
      {\sphinxincludegraphics{celabel_1639.png}\par} %THIS LINE CAUSES POLYGLOSSIA ERROR (but not when placed just below \sphinxlogo...)
      \vfill\vfill
      {\large
       %\@date \par
       \vfill
       \py@authoraddress \par
      }%
    \end{flushright}%\par


Anyway, I worked around this problem using the latex_logo feature, which can also put an image on the title page,I see now, as I discovered by seeing the \sphinxlogo line.

Out of curiosity I would like to understand why the \sphinxincludegraphics causes the problem - guess I'm too latex newbie for that. But that's just nice to have.

jfbu

unread,
Sep 29, 2019, 9:13:17 AM9/29/19
to sphinx...@googlegroups.com
Le 28/09/2019 à 16:52, Pieter Claeys a écrit :
> *About pdflatex with greek*
> I then then got quite a bit further, only remaining problem was that
> pdflatex erorred on the copyright © and trademark ™ characters. Deleting
> those built the document, and indeed, as you mentioned, every roman
> character was converted to Greek alphabet. That was already fine for me, I
> just needed some Greek translation:-)

Hi Pieter,

Only answering that bit. I think you have hit against some bug
of core LaTeX package babel in presence of hyperref.

(I may make a bug report after some more digging to make sure
I have well analyzed the problem).

To fix that I added this to my conf.py

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
'papersize': 'a4paper',

'fontenc': r'\usepackage[LGR,T1]{fontenc}',

'preamble': r'''
\AtBeginDocument{\renewcommand\ensureascii[1]{{\fontencoding{T1}\selectfont#1}}}
'''
}


where the fix is the 'preamble' key

(by the way I suppressed X2 from fontenc options, because this is for cyrillic support)

The bug is that babel package (which provides \ensureascii) uses PU encoding
which is some device of package hyperref for bookmarks.

I believe this is a bug of babel. (perhaps a known issue)

This being said, Greek language is **not** supported by Sphinx + pdflatex
(I should have stated that clearer earlier but I was not sure
myself, nothing existed in Sphinx documentation, even before
I started botchering it ;-) )
mainly for the reasons I stated which is that the set-up is
fine
only for a document using exclusively the Greek script and
nothing Ascii/Latin.

Thus I am **very** glad that Sphinx + xelatex does work for you...

Last remark: the \ensureascii things is for LaTeX babel package
version 3.9i or later, babel is one of those packages which do
not bother communicating to user a complete change log
matching version numbers and release dates and the relatively
new github repo has no tags. But with some digging in babel.dtx
I found
% \changes{babel~3.9i}{2014/02/14}{Macro added, to replace
% \cs{textlatin} and friends}
thus I
guess this means you need TeXLive 2014 at least.
(Sphinx currently officially requires TeXLive 2015 at least
or Distro packaging of the same like Debian thus we are
safe supposedly).

Best,

Jean-François


jfbu

unread,
Sep 29, 2019, 6:01:10 PM9/29/19
to sphinx...@googlegroups.com
Hi Pieter,

Le 28/09/2019 à 16:52, Pieter Claeys a écrit :
> Another half a day later I now see that this was caused by a line that I
> added to sphinxmanual.cls (named sphinxmanual_customqaweb.cls). I add an
> extra image on the title page, with this line:
> {\sphinxincludegraphics{celabel_1639.png}\par}
> ... which cases the polyglossia problem on xelatex , not on pdflatex.
> I still don't understand why this breaks things ; it's almost identical as
> the \sphinxlogo method
> \begin{flushright}%
> \sphinxlogo
> \py@HeaderFamily
> {\Huge \@title \par}
> {\itshape\LARGE \py@release\releaseinfo \par}
> \vfill
> {\LARGE
> \begin{tabular}[t]{c}
> \@author
> \end{tabular}\kern-\tabcolsep
> \par}
> {\sphinxincludegraphics{celabel_1639.png}\par} %THIS LINE CAUSES
> %POLYGLOSSIA ERROR (but not when placed just below \sphinxlogo...)
> \vfill\vfill
> {\large
> %\@date \par
> \vfill
> \py@authoraddress \par
> }%
> \end{flushright}%\par
>
>
> Anyway, I worked around this problem using the latex_logo feature, which
> can also put an image on the title page,I see now, as I discovered by
> seeing the \sphinxlogo line.
>
> Out of curiosity I would like to understand why the \sphinxincludegraphics
> causes the problem - guess I'm too latex newbie for that. But that's just
> nice to have.
>

I. You have a talent for finding core LaTeX bugs. (or perhaps here
a polyglossia bug).

The problem arises from a bad interaction with "draft" option
of \includegraphics LaTeX. Turns out the draft option triggers
some typesetting in monospace font in some box. By itself
this is ok, but \py@HeaderFamily does \sffamily\bfseries

Turns out that issueing \ttfamily after the \bfseries triggers
the problem. This explains why the location of \sphinxincludegraphics
matters.

I have raised a ticket

https://github.com/reutenauer/polyglossia/issues/306

but it may be a fontspec issue rather. I am not familiar
enough with polyglossia to tell.

II.

>> Only answering that bit. I think you have hit against some bug
>> of core LaTeX package babel in presence of hyperref.
>>
>> (I may make a bug report after some more digging to make sure
>> I have well analyzed the problem).


See

https://github.com/latex3/babel/issues/30

III.

> Indeed it works out of the box (at least on Linux) when
> latex_engine=xelatex. So I will switch to building everything (all
> languages) with xelatex (please warn me if that's a bad idea). I have some
> Chinese, Korean and Japanse translations on the longer term roadmap, so
> xelatex hopefully deals with that as well.


For Japanese, don't set latex_engine. Sphinx uses platex which is
a special latex engine especially for Japanese support. It will
do this automatically on language="ja".

For Chinese, I think xelatex + \usepackage{xeCJK} will work,
and you can see there

https://github.com/sphinx-doc/sphinx/pull/6398/files

that it is automatized now in Sphinx 2.1.0
Again, no need to set latex_engine, it is now automatically 'xelatex' for Chinese

For Korean, perhaps the Chinese setting will work? (CJK = Chinese, Japanese, Korean)
But you need to manually set latex_engine to 'xelatex'
and use the 'fontenc' key to add r'\usepackage{xeCJK}'

Best,

Jean-François

jfbu

unread,
Sep 29, 2019, 6:28:15 PM9/29/19
to sphinx...@googlegroups.com
Hi Pieter

Le 30/09/2019 à 00:00, jfbu a écrit :
> I. You have a talent for finding core LaTeX bugs. (or perhaps here
> a polyglossia bug).
>
> The problem arises from a bad interaction with "draft" option
> of \includegraphics LaTeX. Turns out the draft option triggers
> some typesetting in monospace font in some box. By itself
> this is ok, but \py@HeaderFamily does \sffamily\bfseries
>
> Turns out that issueing \ttfamily after the \bfseries triggers
> the problem. This explains why the location of \sphinxincludegraphics
> matters.
>
> I have raised a ticket
>
> https://github.com/reutenauer/polyglossia/issues/306
>
> but it may be a fontspec issue rather. I am not familiar
> enough with polyglossia to tell.


arrgggh ... I now understand the problem.

The GNU-FreeFont for Bold Monospace does not support the Greek Script!

The non bold monospace does support it.

This is annoying limitation of GNU FreeMono

But this give me occasion to insist that xelatex by itself
does not solve problems if you don't have appropriate fonts...

One could have hoped however that polyglossia would not
raise a build crashing error but use some substitute.

Indeed the reported error in my github polyglossia ticket
arises in strange circumstances

This being said you can probably fix it (untested) this way

latex_elements = {
'fontpkg': r'''
\setmainfont{FreeSerif}[
Extension = .otf,
UprightFont = *,
ItalicFont = *Italic,
BoldFont = *Bold,
BoldItalicFont = *BoldItalic
]
\setsansfont{FreeSans}[
Extension = .otf,
UprightFont = *,
ItalicFont = *Oblique,
BoldFont = *Bold,
BoldItalicFont = *BoldOblique,
]
\setmonofont{FreeMono}[
Extension = .otf,
UprightFont = *,
ItalicFont = *,
BoldFont = *,
BoldItalicFont = *,
]
''',
}

(and of course latex_engine = 'xelatex')

What this does is modify the monospace font to
use the normal variant even for Bold and Italic
because only the upright variant supports the Greek script.

(but my mwe at https://github.com/reutenauer/polyglossia/issues/306
throws an error only on second usage of \ttfamily,
and output looked fine and seemingly did use bold FreeMono
even for Greek --- this is all Greek to me! )


Best,

Jean-François

jfbu

unread,
Sep 30, 2019, 6:10:25 AM9/30/19
to sphinx...@googlegroups.com
Le 28/09/2019 à 16:52, Pieter Claeys a écrit :
> That was already fine for me, I
> just needed some Greek translation

Hi Pieter

I have submitted a PR to Sphinx

https://github.com/sphinx-doc/sphinx/pull/6711

With it, xelatex would have been used by default
(with an added fix see discussion at
https://github.com/reutenauer/polyglossia/issues/306)

This will be integrated hopefully into Sphinx 2.3.0
or 2.2.1 if there is such a release.

Don't set explicitely 'fontpkg', 'fontenc' or any
such key then, all is automatic from language = 'el'

Best

Jean-François

Reply all
Reply to author
Forward
Message has been deleted
0 new messages