TransWikia.com

What is wrong with my system setup?

TeX - LaTeX Asked by ophage on April 2, 2021

I bought a new computer with windows10, which I installed MikTeX2.9.
The previous LaTeX file failed to compile in this new system.
The follwing is a min. example:

documentclass{book}
usepackage{fontspec}
usepackage[BoldFont,SlantFont,CheckSingle=true]{xeCJK} 
usepackage{CJKnumb}
setmainfont{Times New Roman}
setCJKmainfont{DFT_HZ5.TTC} 
begin{document}
請見本書第CJKnumber{ref{coding}}章)。
end{document}

You do not need to use DFT_HZ5.TTC any other Chinese font is the same.
The following is the log file:

....
....
Font)                  TU/TimesNewRoman(0)/m/n --> TU/TimesNewRoman(0)/b/n on 
input line 7.
LaTeX Font Info:    Overwriting math alphabet `mathit' in version `bold'
(Font)                  OT1/cmr/bx/it --> TU/TimesNewRoman(0)/b/it on input lin
e 7.
LaTeX Font Info:    Overwriting math alphabet `mathsf' in version `bold'
(Font)                  OT1/cmss/bx/n --> TU/lmss/b/n on input line 7.
LaTeX Font Info:    Overwriting math alphabet `mathtt' in version `bold'
(Font)                  OT1/cmtt/m/n --> TU/lmtt/b/n on input line 7.

! Missing number, treated as zero.
<to be read again> 
                   protect 
l.8 隢?

It is not peculiar, because what is inside CJKnumber is undefined.
The program should popup and ask me, and I simple need to hit a return
But it did not popup.
The program simply break here.

However, if I remove the other Chinese character, the program become

documentclass{book}
usepackage{fontspec}
usepackage[BoldFont,SlantFont,CheckSingle=true]{xeCJK} 
usepackage{CJKnumb}
setmainfont{Times New Roman}
setCJKmainfont{DFT_HZ5.TTC} 
begin{document}
CJKnumber{ref{coding}}
end{document}

It is fine.
What is wrong with my system setup?

One Answer

Similar to this answer, the error is caused by the fact that ref{<label>} is not fully expandable (mainly because the null in @setref). Instead, you can use the fully expandable command getrefnumber{<label>} from refcount package.

Full example:

documentclass{book}
usepackage[BoldFont,SlantFont,CheckSingle=true]{xeCJK} 
usepackage{CJKnumb}
usepackage{refcount}

begin{document}
chapter{title}label{coding}
第CJKnumber{getrefnumber{coding}}章
end{document}

Alternatively, to have consistent counter output format, it is recommended to (re)define the<counter> command.

documentclass{book}
usepackage[BoldFont,SlantFont,CheckSingle=true]{xeCJK} 
usepackage{CJKnumb}

renewcommand{thechapter}{CJKnumber{arabic{chapter}}}

begin{document}

chapter{title}label{coding}
第ref{coding}章

end{document}

Note that CJKnumber accepts a number, not counter name, so we firstly use arabic{chapter} to get the number.

This usage is more common.

Answered by muzimuzhi Z on April 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP