3

To quote a dictum in Chinese in a new page before my thesis in English, I would like to combine the answers to the two post Add a quote to a blank page centered and How does one type Chinese in LaTeX?. I have used \documentclass{report}, and just want to typeset only a few Chinese charecter. I chose xeCJK with XeLaTeX. My code is as follows. When I compile it, it gives me some errors:

you should not be loading the inputenc package

XeTeX expects the source to be in UTF8 encoding

some features of other encodings may conflict, resulting in poor output.

! Missing $ inserted.

Could somebody help me out. I have been struggling against this problem for a long time. Please note that in this example I include all the necessary characters of concern, such as a bold dot between 语文 and 长城.

\documentclass[12pt,a4paper,twoside]{report}
\usepackage[latin1]{inputenc}

\usepackage{xeCJK}
\setCJKmainfont{SimSun}

\usepackage{lmodern}%for quote page
\newlength\longest

\begin{document}
\clearpage
\thispagestyle{empty}
\null\vfill


\settowidth\longest{\huge 我正在认真学习的中文。}
\centering
\parbox{\longest}{%
  \raggedright{\huge%
  我正在认真学习的中文。\\
  北京;\\
  彩虹;\\
  柔中带刚。   \par\bigskip
  }
  \raggedleft\Large 《语文$\bm{\cdot}$长城》 \par%
}

\vfill\vfill

\clearpage

\end{document}
  • 1
    The error message is pretty clear. If you are building your document with XeLaTeX, you do not need \usepackage[latin1]{inputenc}, the engine already expects UTF8. Actually, as the error message says you "should not" load inputenc. – gusbrs Aug 9 '17 at 15:57
  • The simplest way is to typeset the quotation in a separate document, maybe using standalone, producing a cropped PDF file and including it as graphics. – egreg Aug 9 '17 at 16:56
3

The simplest way is to write a separate file, say chinesequote.tex like

\documentclass[border=4]{standalone}

\usepackage{xeCJK}
\setCJKmainfont{SimSun}

\usepackage{textcomp}

\begin{document}
\Huge

\begin{tabular}{@{}l@{}}
  我正在认真学习的中文。\\
  北京;\\
  彩虹;\\
  柔中带刚。\\[\bigskipamount]
  \multicolumn{1}{r}{\Large 《语文\textbf{\textperiodcentered}长城》}
\end{tabular}

\end{document}

and compile it to a PDF file. Then you can simply include the PDF as graphics; this way you are not forced to change encodings or engine (also pdflatex would work):

\documentclass[12pt,a4paper,twoside]{report}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}

\begin{document}

\clearpage

\thispagestyle{empty}

\vspace*{\stretch{1}}

\begin{center}
\includegraphics{chinesequote}
\end{center}

\vspace*{\stretch{2}}

\clearpage

\end{document}

enter image description here

  • @ egreg thanks for your solution. actually, I already have a separate file for titlepage and between the titlepage and the quote page, there are still a few pages. Thus I prefer to write it into the main tex file. One more question: does \usepackage{textcomp} have to do with \textperiodcentered only in your code? Thanks! – jsxs Aug 10 '17 at 1:24
  • @jsxs Yes, \textperiodcentered requires textcomp – egreg Aug 10 '17 at 8:00
  • Thanks @egreg, after I struggle with this problem for several days. Finally, I found that your solution is the most robust with widest feasibility!! Sorry for the late accept. And thank you very much! – jsxs Aug 14 '17 at 2:35
1

Removing inputenc, which the error message explicit tells you to do, and adding bm (because you use \bm), your code compiles fine here:

\documentclass[12pt,a4paper,twoside]{report}
%\usepackage[latin1]{inputenc}

\usepackage{xeCJK}
%\setCJKmainfont{SimSun} %unfortunately, I don't have the font installed, you can uncomment it, of course.
\usepackage{bm}  %<=== this had to be added, once you use \bm
\usepackage{lmodern}%for quote page
\newlength\longest

\begin{document}
\clearpage
\thispagestyle{empty}
\null\vfill


\settowidth\longest{\huge 我正在认真学习的中文。}
\centering
\parbox{\longest}{%
  \raggedright{\huge%
  我正在认真学习的中文。\\
  北京;\\
  彩虹;\\
  柔中带刚。   \par\bigskip
  }
  \raggedleft\Large 《语文$\bm{\cdot}$长城》 \par%
}


\vfill\vfill

\clearpage

\end{document}

Resulting in:

enter image description here

  • It's a petty I can't understand what's written... – gusbrs Aug 9 '17 at 16:19
  • Hi @gusbrs, thank you, I compile your code with XeLaTeX and use PDF Preview. What I saw is messy code...(imgur.com/a/XGj9h) – jsxs Aug 10 '17 at 1:31
  • @jsxs, do you get any error messages? By my code you mean exactly my code, or with the font selection uncommented? – gusbrs Aug 10 '17 at 1:55
  • Yes, exactly your code @gusbrs, I copied it directly. There is no error, warning, and bad box. No any error message. – jsxs Aug 10 '17 at 2:09
  • @jsxs, then I cannot be of much assistance. I can't reproduce your result, and have no information about what might be wrong. If egreg's solution works for you, I suggest you use it. One separate file more in a whole thesis is certainly to be considered a minor inconvenience, if at all. If this is really not suitable to you, I suggest you ask a follow up question from this one (mentioning this one, and emphasizing what is different from the original question). Indeed, the problem here was the use of inputenc with XeLaTeX, and that seems to be solved. – gusbrs Aug 10 '17 at 2:30

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.