使用Latex进行中文排版

LaTex是个好东西,我希望你有.

安装CJK

LaTex排版起初是专门为英文排版设计的,对于亚洲双字节文字并不支持,但是Werner Lemberg 编写了CJK宏包来支持双字节字体。CJK 是中文(Chinese)、日文(Japanese)、韩文(Korean)三国文字的缩写。下面简单介绍windows环境下安装CJK的步骤。

  1. 下载并安装MiKTeX。点击此处下载
  2. 点击【开始】–【所有程序】–【MiKTeX 2.9】–【Maintenance (Admin)】–【MiKTeX Settings (Admin)】,此时会弹出设置菜单,选择”Packages”选项卡。在左边”MiKTeX Packages“目录树中展开”Language Support”,勾选”Chinese Japanese Korean“,从而选中该目录项下面的全部子项。
  3. 点击应用开始下载。 或者点击【start package manager】在弹出的包管理器中搜索下载这三个文件包
  4. 注意 下载CJK的时候一定要选择中国的镜像,否则会出现下载超时断开连接的情况。
    菜单

启用字体

这一步十分重要,之前楼主下载安装CJK后没有进行这一步,百般不得编译成功,总是会提示 source file not found ,但在进行这一步后就能编译成功了。

  打开命令窗口CMD(以管理員身份执行)"

  输入:

 initexmf -u

  等一小会儿,让命令执行完,然后再输入:

  initexmf --edit-config-file updmap

  此时会出现一个笔记本,我们就要输入要启用的字型了:

  Map cwmu.map
  Map cwku.map
  Map cwfsu.map
  Map cwhbu.map
  Map cwyu.map

  保存,关闭,接着在控制台输入命令:

  initexmf --mkmaps

  命令完成后,就大功告成了。

QuickStart

\documentclass[12pt]{article}
\usepackage{CJK}

\begin{document}
\begin{CJK*}{GB}{song}

本文使用中文宋体,This article uses Chinese Song Ti characters。
{\CJKfamily{kai}这一句是中文楷体。}
本句以下仍然是中文宋体。

\end{CJK*}
\end{document}

在上面的例子中可以看到,所有的中文都放在 \begin{CJK*}{GB}{...} 和\end{CJK*} 中间 在文件的开头要加上\usepackage{CJK}, 如果是big5编码,只需要将{GB}换成{Bg5},其它与西文LATEX一致

通用模版

简单的报告模版


\documentclass[a4paper, 11pt]{article}

%%%%%% 导入包 %%%%%%
\usepackage{CJKutf8}
\usepackage{graphicx}
\usepackage[unicode]{hyperref}
\usepackage{xcolor}
\usepackage{cite}
\usepackage{indentfirst}

%%%%%% 设置字号 %%%%%%
\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}

%%%% 设置 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}
\begin{CJK}{UTF8}{gbsn}

%%%% 定理类环境的定义 %%%%
\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{大规模分布式系统环境下的性能监测与跟踪调试工具的\\研究成果综述}
\author{傅海平\footnote{电子邮件: haipingf@gmail.com,学号: 201128013229018}\\[2ex]
\xiaosihao 中国科学院计算技术研究所\\[2ex]
}
\date{20125月}


%%%% 以下部分是正文 %%%%  
\maketitle
\tableofcontents
\newpage
在此输入正文,中英文均可。
\end{CJK}
\end{document}

亲测可用的中文模版在我的Git上可以访问到 https://github.com/whu-king/TexTemplate
更多模版访问Latex编辑部网站 http://www.latexstudio.net/hulatex/templet/graduateThesis.htm

问题解决

  • ! Argument of \CJK@XX has an extra }.
    首先确保花括号{}是匹配的,再查看 \end{CJK*} 或 \end{CJK} 前边有没有多余的符号,比如\\等, 进行分段直接空一行 , 不推荐使用\\ 如果再不行, 只有用最后一招了, 在\end{CJK* }前加入命令: \clearpage

  • CJKCaptain{GB}报错
    GB.cpx发生错误,去掉这一行声明,或者下载完整的GB.cpx替换坏掉的本地GB.cpx.
    参考链接 http://www.newsmth.net/nForum/#!article/TeX/219410

  • 5
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值