下面是我日常使用的一个Latex中英文混排的论文模板。借助于cmap包,能支持PDF的拷贝,中文书签。在编译的时候最好用latexpdf进行编译。
具体的使用方法是:
\documentclass[11pt, a4paper]{article}
\input{head} %%%包含我提供的头文件
\begin{document}
\begin{CJK*}{GBK}{song}
This is your document
在这里开始您的大作.......
\end{CJK*}
\end{document}
下面是 head.tex的具体内容:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
Latex通用中英文混排模板
%
% Kevin Xin
(xintianqing@gmail.com)
%
%
2007-12-8
%
% 支持的功能:pdflatex和latex/dvipdf
% 1.代码插入(直接写和导入源文件)
% 2.图片插入
% 3.超链接
% 4.配合gbk2uni生成中文索引
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 不用CJK支持,在导言区加入中文
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\@tempcnta=128
\loop \catcode\@tempcnta=13 \ifnum\@tempcnta<255
\advance \@tempcnta \@ne
\repeat
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
输入编码设置
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 创建中文可以复制的PDF
\usepackage{cmap}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 定义是用 pdftex 还是 latex 的宏 \ifpdf
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifpdf
\ifx\pdfoutput\undefined
\pdffalse
\else
\pdfoutput=1
\pdftrue
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
CJK 包的设置,支持中英文混排
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{CJK}
%正确分行
\CJKtilde
% 中文段落首行缩进
\usepackage{indentfirst}
%%%%%%%
重新定义中文字体
%%%%%%%%%%%%%
% 宋体
\newcommand{\song}{\CJKfamily{song}}
% 仿宋体
\newcommand{\fangsong}{\CJKfamily{fs}}
% 楷体
\newcommand{\kai}{\CJKfamily{kai}}
% 黑体
\newcommand{\hei}{\CJKfamily{hei}}
% 隶书
\newcommand{\li}{\CJKfamily{li}}
% 幼圆
\newcommand{\youyuang}{\CJKfamily{you}}
%%%%%%%
重新定义中文字号
%%%%%%%%%%%%%
% 四号
\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
}
\begin{CJK*}{GBK}{song}
%%测试中文间距
\newlength\onechineseword
\settowidth\onechineseword{字}
\end{CJK*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
页边距的设置
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%修改上下边距
\topmargin = 0pt
%文本的宽度
\textwidth= 165mm
%文本的高度
\textheight= 240mm
%修改左右边距
\oddsidemargin =1pt
\evensidemargin = 0pt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
页眉和页脚的设置
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 支持页眉和页脚
\usepackage{fancyhdr}
\begin{CJK*}{GBK}{song}
\pagestyle{fancy}
%\renewcommand{\chaptermark}[1]{%
%\markboth{\thechapter.\ #1}{}
%}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
%删除当前页脚和页眉的设置
\fancyhf{}
% E-奇数页,O-偶数页
% L-页眉或页脚的左边,R-页眉或者页脚的右边
% C-页眉或页脚的中间
% H-页眉,F-页脚
% \thepage 显示当前页码
% 在奇数页的左侧,偶数页的右侧显示页码
%\fancyhead[LE,RO]{\bfseries\thepage}
% 在页眉的右侧显示页码
\fancyhead[R]{\bfseries\thepage}
% \rightmark 包含了页面中第一个\markboth的右参数,
% 或者第一个\markright的唯一参数
% 在偶数页左侧显示
%\fancyhead[LO]{\bfseries\rightmark}
% \leftmark 包含了页面中最后一个\markboth的左参数
%\fancyhead[RE]{\bfseries\leftmark}
% 在页眉的左侧显示学校名称
\fancyhead[L]{\bfseries Dalian University of Technology}
%\fancyhead[L]{\bfseries RMI 入门使用}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{\baselineskip}
\fancypagestyle{plain}{
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
}
%页眉的设置
\pagestyle{fancy}
\end{CJK*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
插图设置
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifpdf
\usepackage[pdftex]{graphicx}
\pdfcompresslevel=9
\else
\usepackage{graphicx}
\DeclareGraphicsRule{.jpg}{eps}{.bb}{}
\DeclareGraphicsRule{.png}{eps}{.bb}{}
\fi
%% 图片路径: img/
%% 要插入的图片放在这个文件夹
\graphicspath{{img/}}
%% 定义插图规则:系统会查找后缀的图片
%% 在插入图片时不用写后缀
\DeclareGraphicsExtensions{.jpg, .eps, .gif, .bmp, {}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
源代码引用设置
%%
%% 源代码中最好不用中文注释,会出错!!!%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 使用颜色宏包,语法高亮显示
\usepackage{xcolor}
%使用该包引用源代码
\usepackage{listings}
\lstset{,%
tabsize=4,
%
frame=shadowbox, %把代码用带有阴影的框圈起来
commentstyle=\color{red!50!green!50!blue!50},%浅灰色的注释
rulesepcolor=\color{red!20!green!20!blue!20},%代码块边框为淡青色
keywordstyle=\color{blue!90}\bfseries, %代码关键字的颜色为蓝色,粗体
showstringspaces=false,%不显示代码字符串中间的空格标记
stringstyle=\ttfamily, % 代码字符串的特殊格式
keepspaces=true, %
breakindent=22pt, %
numbers=left,%左侧显示行号
stepnumber=1,%
numberstyle=\tiny, %行号字体用小号
basicstyle=\footnotesize, %
showspaces=false, %
flexiblecolumns=true, %
breaklines=true, %对过长的代码自动换行
breakautoindent=true,%
breakindent=4em, %
escapeinside={} ,%跳脱在 之间得字符
%escapeinside=``, %
aboveskip=1em %代码块边框
}
% 使用方法:
% \begin{lstlisting}[language=JAVA]
% 这里插入源代码...
% \end{lstlisting}
% 或者直接从外部文件导入:
% \lstinputlisting[language={[ANSI]C}]{test.c}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
超链接、书签的设置
|