Set italic text failed in new command definition

1,017

The package xeCJK provides AutoFakeSlant option. There is also AutoFakeBold. I do not have the font you called, so I will illustrate this by Arial Unicode MS.

Notice that latin letters are typeset in Latin Modern since \setCJKmainfont and \newCJKfontfamily affect only ideographs.

\documentclass{book}
\usepackage{xeCJK} %Use Chinese fonts
\setCJKmainfont{Arial Unicode MS}
\newCJKfontfamily\subheadfont[AutoFakeSlant]{Arial Unicode MS} %Define '\subheadfont'
\newcommand{\subhead}[1]{{\itshape \flushright \subheadfont --#1 \par}}

\begin{document}
\chapter{My Article}
\subhead{This is 副标题}
Some content in the article. 一些中文内容。
\end{document}
Share:
1,017

Related videos on Youtube

Trams
Author by

Trams

Updated on December 29, 2020

Comments

  • Trams
    Trams almost 3 years

    I'm defining new commands in my .tex file. Here's my code:

    \newcommand{\subhead}[1]
      {
        {\itshape \flushright \subheadfont --#1 \par}
      }
    

    I'm going to define a command that make some text(from parameter) as a standalone subhead of certain article in a book. However, the parameter text in this command turns out not italic. What's the problem and how can I fix it?

    Thanks~

    Some supplement: It maybe helpful to write down entire document I wrote:

    \documentclass{book}
    \usepackage{fontspec} %Use Chinese fonts
    \XeTeXlinebreaklocale "zh"
    \XeTeXlinebreakskip = 0pt plus 1pt
    \setmainfont{Microsoft YaHei}
    \newfontfamily\subheadfont{FZLiShu-S01S} %Define '\subheadfont'
    \newcommand{\subhead}[1]{{\itshape \flushright \subheadfont --#1 \par}}
    
    \begin{document}
    \chapter{My Article}
    \subhead{This is 副标题}
    Some content in the article. 一些中文内容。
    \end{document}
    
    • Au101
      Au101 almost 8 years
      As an aside: It's not a good idea to use space characters in command definitions, they can introduce unwanted space, instead you should use the % to comment them out if you wish to break a line or indent. I can't show you in the comments, but you would want a % after your { on the second line and at the end of the third line too
    • Au101
      Au101 almost 8 years
      What is \subheadfont? This is ... new to me, how have you defined it? Assuming there is a \subheadfont it is possible that it selects a font which does not have true italics
    • Trams
      Trams almost 8 years
      @Au101 Yeah, I should pay more attention on the space. I forgot to tell you that I'm using package fontspec and defined my own font used for subhead as \subheadfont.
    • Henri Menke
      Henri Menke almost 8 years
      @Trams Just compose a minimal working example (MWE) and save the time explaining all the details.
    • David Carlisle
      David Carlisle almost 8 years
      al the heading code in your example is presumably not relevant, just make an example document that defines the commands you use then does \itshape \subheadfont abc it will be italic or not depending on how you defined \subheadfont. perhaps it is enough to instead do \subheadfont \itshape abc it all depends on code you have not shown.
    • egreg
      egreg almost 8 years
      As far as I can see, the font FZLiShu-S01S is only available in upright shape. Does italic make sense for Chinese?
    • Symbol 1
      Symbol 1 almost 8 years
      @egreg quick answer: no. But since MS Word produces fake italic, people think the TeX should be able to do it as well. So in package xeCJK there is AutoFakeSlant option.