0

How do I set a fallback font for LaTex export to pdf?

I have the following setting in my init.el.

(setq org-latex-classes
      '(("article"
         "
\\documentclass[12pt,a4paper]{article}

\\usepackage{xeCJK}
%\\usepackage[heading]{CJK}
\\usepackage{zhnumber} % package for Chinese formatting of date time (use /zhtoday)
%\\usepackage[yyyymmdd]{datetime} % set date time to numeric

% Set default indentation

\\setlength\\parindent{12pt}

% Set Paper Size, Page Layout (another variable is 'bindingoffset')
\\usepackage[margin = 1.5in, paper = a4paper, inner = 2.5cm,
outer = 2.5cm, top = 3cm, bottom = 2.5cm]{geometry}

% Keep paragraph indentation while having a line break in between paragraphs.
\\edef\\restoreparindent{\\parindent=\\the\\parindent\\relax}
\\usepackage{parskip}
\\restoreparindent

% Indent first paragraph.
\\usepackage{indentfirst}

\\usepackage{titlesec}
\\usepackage{titling}
\\usepackage{fontspec} % packages for title and section-heading font setting.

% Set Font.
\\setsansfont{Arial Unicode MS}
\\setmainfont{Calibri} % Set serifed font to Calibri. Originally set to 'Times New Roman', but it cannot display certain characters such as ①②③.
\\setCJKmainfont{MingLiU}
\\setCJKsansfont{Kaiti TC} % Set Chinese font. NOTE: Remember to append CJK before of the font class. CJK HAS to be there for the font to show.

\\titleformat*{\\section}{\\fontsize{16}{18}\\bfseries\\sffamily}
\\titleformat*{\\subsection}{\\fontsize{14}{16}\\bfseries\\sffamily}
\\titleformat*{\\subsubsection}{\\fontsize{12}{14}\\bfseries\\sffamily} % Set formats for each heading level. 'sffamily' will point to the sans-serif font. In this case, 「楷體」.
\\renewcommand{\\maketitlehooka}{\\sffamily} % Set title font.

% Set quotation font.
\\usepackage{etoolbox}
\\newCJKfontfamily\\quotefont{Kaiti TC}
\\AtBeginEnvironment{quote}{\\quotefont\\normalsize}

% Tweak default settings.
\\renewcommand{\\baselinestretch}{1.2} % Set line width.
\\renewcommand{\\contentsname}{目次} % Translate content page title to Chinese. (Could possibly be done automatically with '\\usepackage[heading]{CJK}'. TODO experiment. )

% For text-boxes

\\usepackage{mdframed}
\\BeforeBeginEnvironment{minted}{\\begin{mdframed}}
\\AfterEndEnvironment{minted}{\\end{mdframed}}

% [FIXME] ox-latex 的設計不良導致 hypersetup 必須在這裡插入
\\usepackage{hyperref}
\\hypersetup{
  colorlinks=true, %把紅框框移掉改用字體顏色不同來顯示連結
  linkcolor=[rgb]{0,0.37,0.53},
  citecolor=[rgb]{0,0.47,0.68},
  filecolor=[rgb]{0,0.37,0.53},
  urlcolor=[rgb]{0,0.37,0.53},
  pagebackref=true,
  linktoc=all,}
"
         ("\\section{%s}" . "\\section*{%s}")
         ("\\subsection{%s}" . "\\subsection*{%s}")
         ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
         ("\\paragraph{%s}" . "\\paragraph*{%s}")
         ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
        ))

Sample Org Document:

#+OPTIONS: toc:nil

#+BEGIN_QUOTE
㊀㊁㊂ ①②③
#+END_QUOTE

㊀㊁㊂ ①②③

PDF generated:

enter image description here


As apparent from the above example, Kaiti TC contains the characters ㊀ etc. but MingLiU does not.

How can we define a fallback font for CJKmainfont so that ㊀㊁㊂ without the quote can be displayed properly?

0

I've found a working solution with the code below:

\\newCJKfontfamily\\fallbackfont{PingFang TC}
\\newunicodechar{㊀}{{\\fallbackfont ㊀}}
\\newunicodechar{㊁}{{\\fallbackfont ㊁}}
\\newunicodechar{㊂}{{\\fallbackfont ㊂}}
\\newunicodechar{㊃}{{\\fallbackfont ㊃}}
\\newunicodechar{㊄}{{\\fallbackfont ㊄}}
\\newunicodechar{㊅}{{\\fallbackfont ㊅}}
\\newunicodechar{㊆}{{\\fallbackfont ㊆}}
\\newunicodechar{㊇}{{\\fallbackfont ㊇}}
\\newunicodechar{㊈}{{\\fallbackfont ㊈}}

I would appreciate other suggestions to the problem, especially with shorter code.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.