2

when I using xelatex to render this document:

\documentclass[12pt,a4paper,sans]{moderncv}

\moderncvstyle{classic}
\moderncvcolor{green}

\usepackage{ctex}
\usepackage[T1]{fontspec}
\usepackage{tgcursor}
\usepackage[scale=0.75]{geometry}

\setmainfont{lmroman10-regular.otf}
\setlength{\footskip}{149.60005pt}
\setlength{\hintscolumnwidth}{3cm}

\begin{document}
hello world!
\end{document}

shows error:

Option clash for package fontspec. \usepackage

why did this error happen? what should I do to fixed this issue?

4
  • 3
    \usepackage[T1]{fontspec} doesn't make sense. Delete the line. Jun 27 at 15:09
  • I have tried to delete \usepackage[T1]{fontspec} but still could not fixed the issue, show error Undefined control sequence. \begin{document}.
    – Dolphin
    Jun 27 at 15:12
  • 2
    your editor is not showing you error messages in a useful form, you should look at the error messages from tex in the log file which would have shown which options clashed and will show which command is undefined (\@firstname is undefined) Jun 27 at 15:13

1 Answer 1

4

Unfortunately your editor's treatment of error messages makes them completely useless, ignore that and use the errors from tex in the log file.

The first error is

! LaTeX Error: Option clash for package fontspec.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.8 \usepackage
               {tgcursor}
? 

Delete \usepackage[T1]{fontspec}

You then get

! Undefined control sequence.
<argument> \@firstname 
                       {}~\@lastname {}
l.15 \begin{document}
                     
? 

as no first name has been specified, so this runs without error in xelatex

\documentclass[12pt,a4paper,sans]{moderncv}

\moderncvstyle{classic}
\moderncvcolor{green}

\usepackage{ctex}

\usepackage{tgcursor}
\usepackage[scale=0.75]{geometry}

\setmainfont{lmroman10-regular.otf}
\setlength{\footskip}{149.60005pt}
\setlength{\hintscolumnwidth}{3cm}

\firstname{David}
\familyname{Carlisle}
\begin{document}
hello world!
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .