Created
June 20, 2017 14:20
-
-
Save michaelHL/b7142b2d17cbd8033f66ebf25c42ea2d to your computer and use it in GitHub Desktop.
LaTeX cn support
from https://www.zhihu.com/question/41206352
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
作者:王晗 | |
链接:https://www.zhihu.com/question/41206352/answer/146930087 | |
来源:知乎 | |
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 | |
%!TEX TS-program = xelatex | |
%!TEX encoding = UTF-8 Unicode | |
\documentclass[UTF-8,a4paper, 11pt]{article} | |
%%%%%% 导入包 %%%%%% | |
\usepackage{xeCJK} | |
\usepackage{graphicx} | |
\usepackage[unicode]{hyperref} | |
\usepackage{xcolor} | |
\usepackage{cite} | |
\usepackage{indentfirst} | |
\usepackage{amsmath} | |
\usepackage{amssymb} | |
\usepackage{chemfig} | |
%%%%%% 设置字号 %%%%%% | |
\newcommand{\chuhao}{\fontsize{42pt}{\baselineskip}\selectfont} | |
\newcommand{\xiaochuhao}{\fontsize{36pt}{\baselineskip}\selectfont} | |
\newcommand{\yihao}{\fontsize{28pt}{\baselineskip}\selectfont} | |
\newcommand{\erhao}{\fontsize{21pt}{\baselineskip}\selectfont} | |
\newcommand{\xiaoerhao}{\fontsize{18pt}{\baselineskip}\selectfont} | |
\newcommand{\sanhao}{\fontsize{15.75pt}{\baselineskip}\selectfont} | |
\newcommand{\sihao}{\fontsize{14pt}{\baselineskip}\selectfont} | |
\newcommand{\xiaosihao}{\fontsize{12pt}{\baselineskip}\selectfont} | |
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont} | |
\newcommand{\xiaowuhao}{\fontsize{9pt}{\baselineskip}\selectfont} | |
\newcommand{\liuhao}{\fontsize{7.875pt}{\baselineskip}\selectfont} | |
\newcommand{\qihao}{\fontsize{5.25pt}{\baselineskip}\selectfont} | |
%%% 英文相关字体属性 %%%% | |
% \usepackage{fontspec,xltxtra,xunicode} | |
% \defaultfontfeatures{Mapping=tex-text} | |
% \setromanfont[Mapping=tex-text]{Hoefler Text} | |
% \setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Gill Sans} | |
% \setmonofont[Scale=MatchLowercase]{Andale Mono} | |
%%%% 设置 font 属性 %%%% | |
\setCJKmainfont[BoldFont ={STXihei},ItalicFont ={STKaiti}]{STFangsong}%{STSong} %设置中文正体字体,BoldFont设置粗体和斜体样式对应的字体 | |
\setCJKsansfont{STXihei}%设置无衬线样式对应字体 | |
\setCJKmonofont{STFangsong} %设置有衬线样式对应字体 | |
\punctstyle{hangmobanjiao} %行末半角式:所有标点占一个汉字宽度,行首行末对齐 | |
%%%% 设置 section 属性 %%%% | |
\makeatletter | |
\renewcommand\section{\@startsection{section}{1}{\z@}% | |
{-1.5ex \@plus -.5ex \@minus -.2ex}% | |
{.5ex \@plus .1ex}% | |
{\normalfont\sihao\CJKfamily{hei}}} | |
\makeatother | |
%%%% 设置 subsection 属性 %%%% | |
\makeatletter | |
\renewcommand\subsection{\@startsection{subsection}{1}{\z@}% | |
{-1.25ex \@plus -.5ex \@minus -.2ex}% | |
{.4ex \@plus .1ex}% | |
{\normalfont\xiaosihao\CJKfamily{hei}}} | |
\makeatother | |
%%%% 设置 subsubsection 属性 %%%% | |
\makeatletter | |
\renewcommand\subsubsection{\@startsection{subsubsection}{1}{\z@}% | |
{-1ex \@plus -.5ex \@minus -.2ex}% | |
{.3ex \@plus .1ex}% | |
{\normalfont\xiaosihao\CJKfamily{hei}}} | |
\makeatother | |
%%%% 段落首行缩进两个字 %%%% | |
\makeatletter | |
\let\@afterindentfalse\@afterindenttrue | |
\@afterindenttrue | |
\makeatother | |
\setlength{\parindent}{2em} %中文缩进两个汉字位 | |
%%%% 下面的命令重定义页面边距,使其符合中文刊物习惯 %%%% | |
\addtolength{\topmargin}{-54pt} | |
\setlength{\oddsidemargin}{0.63cm} % 3.17cm - 1 inch | |
\setlength{\evensidemargin}{\oddsidemargin} | |
\setlength{\textwidth}{14.66cm} | |
\setlength{\textheight}{24.00cm} % 24.62 | |
%%%% 下面的命令设置行间距与段落间距 %%%% | |
\linespread{1.4} | |
% \setlength{\parskip}{1ex} | |
\setlength{\parskip}{0.5\baselineskip} | |
%%%% 正文开始 %%%% | |
\begin{document} | |
%%%% 定理类环境的定义 %%%% | |
\newtheorem{example}{例} % 整体编号 | |
\newtheorem{algorithm}{算法} | |
\newtheorem{theorem}{定理}[section] % 按 section 编号 | |
\newtheorem{definition}{定义} | |
\newtheorem{axiom}{公理} | |
\newtheorem{property}{性质} | |
\newtheorem{proposition}{命题} | |
\newtheorem{lemma}{引理} | |
\newtheorem{corollary}{推论} | |
\newtheorem{remark}{注解} | |
\newtheorem{condition}{条件} | |
\newtheorem{conclusion}{结论} | |
\newtheorem{assumption}{假设} | |
%%%% 重定义 %%%% | |
\renewcommand{\contentsname}{目录} % 将Contents改为目录 | |
\renewcommand{\abstractname}{摘要} % 将Abstract改为摘要 | |
\renewcommand{\refname}{参考文献} % 将References改为参考文献 | |
\renewcommand{\indexname}{索引} | |
\renewcommand{\figurename}{图} | |
\renewcommand{\tablename}{表} | |
\renewcommand{\appendixname}{附录} | |
\renewcommand{\algorithm}{算法} | |
%%%% 定义标题格式,包括title,author,affiliation,email等 %%%% | |
\title{中英文Latex模版} | |
\author{王晗\footnote{电子邮件: [email protected],学号: 2014141463191}\\[2ex] | |
\xiaosihao 四川大学吴玉章学院\\[2ex] | |
} | |
\date{2017年2月} | |
%%%% 以下部分是正文 %%%% | |
\maketitle | |
\tableofcontents | |
\newpage | |
在此输入正文,中英文均可。 | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment