文章目录
  1. 1. 具体的使用方法如下
  2. 2. 下面是 head.tex的具体内容

下面是我日常使用的一个Latex中英文混排的论文模板,整理与2007年。该模板借助于cmap包,能支持PDF的拷贝,中文书签。在编译的时候最好用latexpdf进行编译。

具体的使用方法如下

1
2
3
4
5
6
7
8
\documentclass[11pt, a4paper]{article}
\input{head} %%%包含我提供的头文件
\begin{document}
\begin{CJK*}{GBK}{song}
This is your document
在这里开始您的大作.......
\end{CJK*}
\end{document}

下面是 head.tex的具体内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 超链接、书签的设置 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[%
dvipdf, %
pdfstartview=FitH,%
CJKbookmarks=true,%
bookmarks=true,%
bookmarksnumbered=true,%
bookmarksopen=true,%
colorlinks=true,%
citecolor=blue,%
linkcolor=blue,%
anchorcolor=green,%
urlcolor=blue%
]{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 其他有用的设置
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{array}
%调整表格行距为默认的1.2倍
\renewcommand{\arraystretch}{1.2}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 导言区结束
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
文章目录
  1. 1. 具体的使用方法如下
  2. 2. 下面是 head.tex的具体内容