XeTeXfontspec and related things in xelatex - texlive

Information and discussion about XeTeX, an alternative for pdfTeX based on e-Tex
Post Reply
annier
Posts: 16
Joined: Mon Sep 14, 2015 4:24 pm

fontspec and related things in xelatex - texlive

Post by annier »

Hi All,
I recently have tried to compile the following tex file in xetex (texlive-2015) in ubuntu 14.04.

Code: Select all

\documentclass{article}
\usepackage{fontspec}
\usepackage{amsmath,amssymb}
%\setmainfont[Ligatures=TeX]{TeX Gyre Pagella} 
\usepackage[CJKnumber,CJKaddspaces,CJKchecksingle,BoldFont]{xeCJK}
\usepackage{mathrsfs}   % 一种常用于定义泛函算子的花体字母,只有大写。
 \usepackage{bm}         % 处理数学公式中的黑斜体的宏包
 \setmainfont[Ligatures=TeX]{LMRoman10}
 \setsansfont[Ligatures=TeX]{LMSans10}
 \setmonofont[Ligatures=TeX]{LMMono10}
\begin{document}

Hello, World!

\end{document}
It produces the following log.
...

Code: Select all

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! xeCJK error: "key-unknown"
! 
! Sorry, but xeCJK/options does not have a key called `CJKaddspaces'.
! 
! The key `CJKaddspaces' is being ignored.
! 
! See the xeCJK documentation for further information.
! 
! Type <return> to continue.
!............................................... 
l.3538 \ProcessKeysOptions { xeCJK / options } 
...

Code: Select all

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! 
! The font "LMRoman10" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  
                                                  
l.8  \setmainfont[Ligatures=TeX]{LMRoman10}
...

Code: Select all

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! 
! The font "LMSans10" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  
                                                  
l.9  \setsansfont[Ligatures=TeX]{LMSans10}
...

Code: Select all

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! 
! The font "LMMono10" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  
                                                  
l.10  \setmonofont[Ligatures=TeX]{LMMono10}
                                           
How can i add the necessary fonts and packages in the texlive 2015 and make it run?

Yours Sincerely,
Anil Kunwar

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

fontspec and related things in xelatex - texlive

Post by Johannes_B »

For the font names, use Latin Modern Roman, Latin Modern Sans and Latin Modern Mono.

In teh xeCJK manual i can spot a CJKspace (i don't read chinese, so ...), but not CJKaddspaces. Where did you get this from? Maybe it was available in an old version and got renamed?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
annier
Posts: 16
Joined: Mon Sep 14, 2015 4:24 pm

fontspec and related things in xelatex - texlive

Post by annier »

Hi Johannes,
Thank you very much for providing me the solutions.
Now i have got the following working examples for my context:

Method - A
  • a). Yes, replacing CJKaddspaces by CJKspace solved the log as shown above.
    b). In context of replacements of LMRoman10 by Latin Modern Roman and so on, the xetex compilation ran successfully.
Working Example

Code: Select all

\documentclass{article}
\usepackage{fontspec}
\usepackage{amsmath,amssymb}
%\setmainfont[Ligatures=TeX]{TeX Gyre Pagella} 
\usepackage[CJKnumber,CJKspace,CJKchecksingle,BoldFont]{xeCJK}
\usepackage{mathrsfs}   % 一种常用于定义泛函算子的花体字母,只有大写。
 \usepackage{bm}         % 处理数学公式中的黑斜体的宏包
 \setmainfont[Ligatures=TeX]{Latin Modern Roman}
 \setsansfont[Ligatures=TeX]{Latin Modern Sans}
 \setmonofont[Ligatures=TeX]{Latin Modern Mono}
% \setromanfont[ItalicFont={MinionPro-It}]{MinionPro-Regular}
%\setmainfont[Mapping=tex-text]{Times New Roman}
%\setsansfont{Helvetica}
%\setmonofont[Scale=MatchLowercase]{Monospace}
%\newfontfamily\hebrewfont[Script=Hebrew]{Ezra SIL}
\begin{document}
\section{中文字的測試}
\section{Hello, World!} 

\end{document}
Method - B
Alternatively, i downloaded and installed the microsoft fonts in the way as described in this link. For CJK fonts, i installed from the Ubuntu Software center.
Working Example

Code: Select all

\documentclass{article}
\usepackage{fontspec}
\usepackage{xeCJK}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
%Select fonts
\setmainfont[Mapping=tex-text]{Times New Roman} % rm
\setsansfont[Mapping=tex-text]{Arial}           % sf
\setmonofont{Courier New}                       % tt
\setCJKmainfont{WenQuanYi Zen Hei} %xelatex 標楷體
%\setCJKmonofont{SimSun}  %xelatex 細明體
\setCJKmonofont{AR PL UKai CN}  %xelatex 細明體
%...
\begin{document}
中文字的測試
\end{document}


Yours Sincerely,
Anil Kunwar
Post Reply