question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fail to build a Thai book using pdflatex when notebook/md has Thai characters as title or header. Need some help

See original GitHub issue

I’m trying to build a pdf from the Jupyter notebook by doing…

  • Create a test book using ‘$ jupyter-book create myb’
  • Add some Thai characters into ‘_config.yml’ (title and author)
  • Add some Thai characters into ‘intro.md’ (Header 1), ‘notebooks.ipynb’ (Header 1, Header 2, text-body), ‘markdown.md’ (Header 1, Header 2, text-body)
  • Build the html using ‘$ jupyter-book build myb/’ <-- No problem. Show Thai language correctly.
  • Create the pdf using ‘$ jupyter-book build myb/ --builder pdflatex’ <-- There is some problems in the book title, author, chapter title.

Expectation I expected the book to properly show the Thai characters as on the website (image below) image

Problem Thai characters in the book title, author, chapter title (Header1 ,2 ,3 …) displays incorrectly (image below). image

I’ve attached both the test book (the source files after modifications mentioned above) and the console output after trying to create the pdf.

Error: `Package pgfplots Warning: running in backwards compatibility mode (unsuitable t ick labels; missing features). Consider writing \pgfplotsset{compat=1.18} into your preamble. on input line 93.

geometry driver: auto-detecting geometry detected driver: xetex (./book.out) (./book.out) (/usr/local/texlive/2022/texmf-dist/tex/generic/stringenc/se-ascii-print.def) Missing character: There is no ไ (U+0E44) in font [FreeSansBold.otf]/OT:script= latn;language=dflt;! Missing character: There is no ท (U+0E17) in font [FreeSansBold.otf]/OT:script= latn;language=dflt;! Missing character: There is no ย (U+0E22) in font [FreeSansBold.otf]/OT:script= latn;language=dflt;!`

List my environment

Jupyter Book : 0.13.0 nbconvert : 6.5.0 Sphinx-external-toc : 0.2.4 MyST-Parser : 0.15.2 MyST-NB : 0.13.2 Sphinx Book Theme : 0.8.1 Jupyter-Cache : 0.4.3 NbClient : 0.5.13

Version of Python. : 3.8 OS : MacOS 12.3.1

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
tubekmtilcommented, Jun 16, 2022

@AakashGfude It doesn’t work, probably because it was placed in the wrong place (I’ve never used latex before (-_-);;; )

From the comments that you and @mmcky sent to me, I have changed the preamble from

\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 = *Oblique,
   BoldFont = *Bold,
   BoldItalicFont = *BoldOblique,
]

– to -->

\setsansfont{Norasi}[
  Extension = .otf,
  UprightFont = *,
  ItalicFont = *-Italic,
  BoldFont = *-Bold,
  BoldItalicFont = *-BoldItalic,
  Scale = 1.1,
  Script = Default,
  Mapping = tex-text
]
\setmainfont{Laksaman}[
  Extension = .otf,
  UprightFont = *,
  ItalicFont = *-Italic,
  BoldFont = *-Bold,
  BoldItalicFont = *-BoldItalic,
  Scale = 1.1,
  Script = Default,
  Mapping = tex-text
]
\setmonofont{Loma}[
  Extension = .otf,
  UprightFont = *,
  ItalicFont = *-Oblique,
  BoldFont = *-Bold,
  BoldItalicFont = *-BoldOblique,
  Scale = 1,
  Script = Default,
  Mapping = tex-text
]

It works well !!! as shown below. Screen Shot 2022-06-16 at 12 30 01

Thank you both of you (@mmcky, @AakashGfude) for pointing me in the right direction.

2reactions
mmckycommented, Jun 8, 2022

@tubekmtil I had a quick search and came across

https://tex.stackexchange.com/questions/113359/latex-and-thai-language

which may contain some helpful hints for you.

My suggestion would be to edit:

  1. _build/latex/book.tex using xelatex to see if you can get the LaTeX side of things working, then
  2. add then add the needed adjustments to your latex preamble via sphinx configuration in _config.yml.

https://jupyterbook.org/en/stable/advanced/sphinx.html#manual-sphinx-configuration

and the sphinx docs for a custom preamble

https://www.sphinx-doc.org/en/master/latex.html

so it would look something like

sphinx
  config:
    latex_elements:
      preamble: >
        <preamble>

and that get’s added to the preamble.

@AakashGfude any other tips / ideas here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

XeTeX \section{} doesn't show Thai fonts - TeX
I found out the way to make the section show the text, thanks to Latex and Thai language. I forgot to set the...
Read more >
Quick check questions and answers Flashcards - Quizlet
Study with Quizlet and memorize flashcards containing terms like What is a ... Provide code to mark the text Gourmet Thai Cooking as...
Read more >
The fancyhdr and extramarks packages - CTAN
This document describes how to customize the page layout of your LaTeX documents, i.e how to change page margings and sizes, headers and...
Read more >
Legrand Orange Book vs THAI language - LaTeX.org
I try to edit Legrand Orange Book for using THAI language many ways. ... with the % commands below to make sure your...
Read more >
Untitled
Fingerboard blackriver brick curb, Omar dengo obregon, Phenyl-5pw column, Watch celtics vs heat online, Notebook ultrafino cce t325 com intel, Thai sub ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found