Skip to content

Instantly share code, notes, and snippets.

@Harry-Chen
Last active November 23, 2018 11:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Harry-Chen/905835e7e76ed8c69375 to your computer and use it in GitHub Desktop.
Save Harry-Chen/905835e7e76ed8c69375 to your computer and use it in GitHub Desktop.
XeLaTeX template for short novel (as book)
\documentclass[zihao=-4,oneside,UTF8]{ctexbook}
\usepackage{titlesec,fancyhdr,xltxtra,hyperxmp}
\usepackage[xetex,a4paper,centering,scale=0.8]{geometry}
\input{config.tex}
\xeCJKsetup{CheckSingle}
\pagestyle{fancy}
\setmainfont{\bookmainfont}
\setCJKmainfont[BoldFont=\bookboldfont,ItalicFont=\bookitalicfont]{\bookmainCJKfont}
\usepackage[bookmarksnumbered,
colorlinks=false,
linkcolor=blue]{hyperref}
\hypersetup{pdfauthor=\bookauthor,
pdftitle=\booktitle,
pdfsubject=\booksubject,
pdfkeywords=\bookkeywords,
pdfcopyright=\bookcopyright,
pdflicenseurl=\booklicenseurl,
pdfdate=\date
pdfdisplaydoctitle=true,
pdflang=\booklang,
pdfstartview=FitH}
\begin{document}
\titlespacing{\chapter}{0cm}{0cm}{1em}
\titleformat{\chapter}{\itshape\centering\Huge}{\chinese{chapter}}{1em} {}
\title{\fontsize{50pt}{50pt}\selectfont{\CJKfontspec{\booktitlefont} \booktitle}}
\author{
\fontsize{20pt}{50pt} \selectfont
\booksubject \\[0.5em]
\fontsize{20pt}{50pt} \selectfont
\bookauthor
\thanks{\bookthanks}
}
\date{\bookdate}
\maketitle
\frontmatter
\tableofcontents
%\thispagestyle{empty}
\mainmatter
\input{content.tex}
\backmatter
\end{document}
\newcommand{\booksubject}{}%Subject
\newcommand{\booktitle}{}%Title
\newcommand{\bookauthor}{}%Author
\newcommand{\bookthanks}{}%Thanks
\newcommand{\bookkeywords}{}%Keywords in metadata
\newcommand{\bookdate}{}%Date in title page
\newcommand{\booklang}{}%PDF language in metadata
\newcommand{\bookcopyright}{}%Copyright in metadata
\newcommand{\booklicenseurl}{}%License URL in metadata
\newcommand{\bookmainfont}{}%Main font for non-CJK characters
\newcommand{\bookmainCJKfont}{}%Main font for CJK characters
\newcommand{\bookboldfont}{}%Font for bold characters
\newcommand{\bookitalicfont}{}%Font for italic characters
\newcommand{\booktitlefont}{}%Font for title
%Add your content here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment