-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.tex
More file actions
executable file
·340 lines (305 loc) · 11.6 KB
/
main.tex
File metadata and controls
executable file
·340 lines (305 loc) · 11.6 KB
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
% 使用ctexart文档类(用XeLaTeX编译,直接支持中文)
\documentclass{ctexart}
%导言区,可以在此引入必要的宏包
\usepackage{boxie}
\usepackage{hyperref}
\usepackage{graphicx}
% ========设置标题的格式========
\ctexset{
section = {
format+ = \zihao{-4} \heiti \raggedright,
name = {,、},
number = \chinese{section},
beforeskip = 1.0ex plus 0.2ex minus .2ex,
afterskip = 1.0ex plus 0.2ex minus .2ex,
aftername = \hspace{0pt}
},
subsection = {
format+ = \zihao{5} \heiti \raggedright,
% name={\thesubsection、},
name = {,、},
number = \arabic{subsection},
beforeskip = 1.0ex plus 0.2ex minus .2ex,
afterskip = 1.0ex plus 0.2ex minus .2ex,
aftername = \hspace{0pt}
}
}
\newcommand{\qtmark}[1]{``#1''}
\title{\Large \heiti 采用tcolorbox宏包设计的用于排版终端窗口和代码的宏
包boxie.sty}
\author{\zihao{4} \fangsong 耿楠\\\small \songti 西北农林科技大学信息
工程学院,陕西$\cdot$杨凌,712100}
\begin{document} %在document环境中撰写文档
\maketitle
\begin{abstract}
在使用\url{https://github.com/latexstudio/ChenLaTeXBookTemplate}提供
的\LaTeX 书籍模板排版时,发现该模板中设计代码盒子环境和命令非常实用,
另外,该模板还提供了排版终端命令窗口的基本思路。基于此,通过研读该模
板的代码,重新设计了用于个Ubuntu、Windows和Mac终端命令窗口的12个排版
环境和12个从文件读取窗口内容的排版命令,以期更为方便的排版终端命令窗
口。
该宏包可以为经常有编写终端命令窗口和代码排版的人员提供帮助,但由于作
者水平有限,一定存在不足之处,欢迎大家多提宝贵意见和建议。
\end{abstract}
\section{终端窗口盒子环境与命令}
\subsection{终端窗口分类}
\begin{itemize}
\item 带底部说明的黑底白字(用于屏幕阅读)
\item 带底部说明的白底黑字(用于打印输出)
\item 无底部说明的黑底白字(用于屏幕阅读)
\item 无底部说明的白底黑字(用于打印输出)
\end{itemize}
\subsection{环境与命令命名规范}
\begin{itemize}
\item 操作系统前缀
\begin{itemize}
\item ubt:Ubuntu
\item win:Windows
\item mac:Mac OS
\end{itemize}
\item 配色中缀
\begin{itemize}
\item dark:黑底白字
\item light:白底黑字
\end{itemize}
\item 底部说明中缀
\begin{itemize}
\item c:有底部说明
\item 空:无底部说明
\end{itemize}
\item 文件后缀
\begin{itemize}
\item file:窗口内容来自文件
\item 空:窗口内容在环境中
\end{itemize}
\end{itemize}
\subsection{环境与命令列表}
共计12个环境,分别是:
\begin{itemize}
\item Ubuntu
\begin{itemize}
\item \qtmark{ubtdarkc}:带底部说明的黑底白字
\item \qtmark{ubtlightc}:带底部说明的白底黑字
\item \qtmark{ubtdark}:无底部说明的黑底白字
\item \qtmark{ubtlight}:无底部说明的白底黑字
\end{itemize}
\item Windows
\begin{itemize}
\item \qtmark{windarkc}:带底部说明的黑底白字
\item \qtmark{winlightc}:带底部说明的白底黑字
\item \qtmark{windark}:无底部说明的黑底白字
\item \qtmark{winlight}:无底部说明的白底黑字
\end{itemize}
\item Mac
\begin{itemize}
\item \qtmark{macdarkc}:带底部说明的黑底白字
\item \qtmark{maclightc}:带底部说明的白底黑字
\item \qtmark{macdark}:无底部说明的黑底白字
\item \qtmark{maclight}:无底部说明的白底黑字
\end{itemize}
\end{itemize}
共计12个命令,分别是:
\begin{itemize}
\item Ubuntu
\begin{itemize}
\item \qtmark{\textbackslash ubtdarkcfile}:带底部说明的黑底白字,内
容来自文件
\item \qtmark{\textbackslash ubtlightcfile}:带底部说明的白底黑字,内
容来自文件
\item \qtmark{\textbackslash ubtdarkfile}:无底部说明的黑底白字,内容
来自文件
\item \qtmark{\textbackslash ubtlightfile}:无底部说明的白底黑字,内
容来自文件
\end{itemize}
\item Windows
\begin{itemize}
\item \qtmark{\textbackslash windarkcfile}:带底部说明的黑底白字,内
容来自文件
\item \qtmark{\textbackslash winlightcfile}:带底部说明的白底黑字,内
容来自文件
\item \qtmark{\textbackslash windarkfile}:无底部说明的黑底白字,内容
来自文件
\item \qtmark{\textbackslash winlightfile}:无底部说明的白底黑字,内
容来自文件
\end{itemize}
\item Mac
\begin{itemize}
\item \qtmark{\textbackslash macdarkcfile}:带底部说明的黑底白字,内
容来自文件
\item \qtmark{\textbackslash maclightcfile}:带底部说明的白底黑字,内
容来自文件
\item \qtmark{\textbackslash macdarkfile}:无底部说明的黑底白字,内
容来自文件
\item \qtmark{\textbackslash maclightfile}:无底部说明的白底黑字,内
容来自文件
\end{itemize}
\end{itemize}
\subsection{基本使用语法}
以黑底白字Ubuntu终端窗口排版为例,其排版语法为:
\subsubsection{环境}
\begin{langPyOne}[tex]{带底部说明的黑底白字环境}
\begin{ubtdarkc}{底部说明}{标题}
窗口内容
\end{ubtdarkc}
\end{langPyOne}
\begin{langPyOne}[tex]{无底部说明的黑底白字环境}
\begin{ubtdark}{标题}
窗口内容
\end{ubtdark}
\end{langPyOne}
\subsubsection{命令}
\begin{langPyOne}[tex]{带底部说明的黑底白字环境}
\ubtdarkcfile{底部说明}{标题}{窗口内容文件名}
\end{langPyOne}
\begin{langPyOne}[tex]{无底部说明的黑底白字环境}
\ubtdarkfile{标题}{窗口内容文件名}
\end{langPyOne}
\subsection{排版示例}
\subsection{Ubuntu终端窗口}
% % 用环境排版,内容直接录入
% \begin{ubtdark}{xxxxxx@xxxxxx-lap:~}
% xxxxxx@xxxxxx-lap:~$ ls
% Desktop Downloads p2 Public Templates Videos
% Documents Music Pictures snap '#test#' workspace
% xxxxxx@xxxxxx-lap:~$
% \end{ubtdark}
% \begin{ubtlight}{xxxxxx@xxxxxx-lap:~}
% xxxxxx@xxxxxx-lap:~$ ls
% Desktop Downloads p2 Public Templates Videos
% Documents Music Pictures snap '#test#' workspace
% xxxxxx@xxxxxx-lap:~$
% \end{ubtlight}
% % 用命令排版,内容来自文件
% \ubtdarkcfile{ls 是查看文件命令}{xxxxxx@xxxxxx-lap:~}{testls.sh}
% \ubtlightcfile{ls 是查看文件命令}{xxxxxx@xxxxxx-lap:~}{testls.sh}
% \subsection{Windows命令行窗口}
% % 用命令排版,内容来自文件
% \windarkfile{显示当前目录中的文件}{test.bat}
% \winlightfile{显示当前目录中的文件}{test.bat}
% % 用环境排版,内容直接录入
% \begin{windarkc}{dir 是查看文件命令}{显示当前目录中的文件}
% C:\Users\Administrator 的目录
% 2018/07/21 15:39 <DIR> .
% 2018/07/21 15:39 <DIR> ..
% 2018/07/13 08:35 <DIR> 3D Objects
% 2018/07/13 08:35 <DIR> Contacts
% 2018/08/06 07:46 <DIR> Desktop
% 2 个文件 6,029,312 字节
% 18 个目录 14,035,107,840 可用字节
% \end{windarkc}
% \begin{winlightc}{dir 是查看文件命令}{显示当前目录中的文件}
% C:\Users\Administrator 的目录
% 2018/07/21 15:39 <DIR> .
% 2018/07/21 15:39 <DIR> ..
% 2018/07/13 08:35 <DIR> 3D Objects
% 2018/07/13 08:35 <DIR> Contacts
% 2018/08/06 07:46 <DIR> Desktop
% 2 个文件 6,029,312 字节
% 18 个目录 14,035,107,840 可用字节
% \end{winlightc}
% \subsection{Mac终端窗口}
% % 用命令排版,内容来自文件
% \macdarkfile{xxxxxx@lap:~}{testsh}
% \maclightfile{xxxxxx@lap:~}{testsh}
% \macdarkcfile{克隆Github远程仓库}{xxxxxx@lap:~}{testsh}
% \maclightcfile{克隆Github远程仓库}{xxxxxx@lap:~}{testsh}
\subsection{通用环境与命令}
定义了2个通用Ubuntu黑底白字样式的终端窗口环境,可以通过可选参数指定窗口内容的语
言,其基本语法是
\begin{langPyOne}[tex]{有底部说明}
\begin{GitExample}[代码语言]{底部说明}{标题}
...
\end{GitExample}
\end{langPyOne}
和
\begin{langPyOne}[tex]{无底部说明}
\begin{GitExampla}[代码语言]{标题}
...
\end{GitExampla}
\end{langPyOne}
及
\begin{langPyOne}[tex]{无底部说明}
\gitfile[代码语言]{标题}{文件名}
\end{langPyOne}
\section{代码排版环境与命令}
\subsection{代码排版样式分类 }
\begin{itemize}
\item 带底部说明无交叉引用
\item 无底部说明无交叉引用
\item 无底部说明有交叉引用
\end{itemize}
\subsection{环境与命令列表}
\subsubsection{环境}
\begin{itemize}
\item \qtmark{langPyTwo}:带底部说明无交叉引用代码排版环境
\item \qtmark{langPyOne}:无底部说明无交叉引用代码排版环境
\item \qtmark{langCVOne}:无底部说明有交叉引用代码排版环境
\end{itemize}
\subsubsection{命令}
\begin{itemize}
\item \qtmark{\textbackslash langPyfile}:无底部说明无交叉引用代码排版
命令,代码带自文件
\item \qtmark{\textbackslash langCVfile}:无底部说明有交叉引用代码排版
命令,代码带自文件
\end{itemize}
\subsection{基本语法}
\begin{langPyOne}[tex]{有底部说明无交叉引用代码排版环境}
\begin{langPyTwo}[语言]{底部说明}{标题}
...
\end{langPyTwo}
\end{langPyOne}
\langPyfile[tex]{无底部说明无交叉引用代码排版环境}{langpyone.tex}
\begin{langPyOne}[tex]{无底部说明有交叉引用代码排版环境}
\begin{langCVOne}[语言][交叉引用标签][显示语言名]{标题}
...
\end{langCVOne}
\end{langPyOne}
\begin{langPyOne}[tex]{排版命令使用}
\langCVfile[语言][交叉引用标签][语言名显示]{标题}{文件名}
\langPyfile[语言]{标题}{文件名}
\end{langPyOne}
其中, 方括号的参数是可选的。\qtmark{[语言名显示]}是显示在标题中要排版
代码的语言名称。
\subsection{代码排版实例}
\begin{langPyTwo}[c]{这是C语言代码排版一个实例}{C语言代码排版
(langPyTwo环境)}
#include<stdio.h>
#include<stdlib.h>
int main()
{
printf("Hello World!\n");
return 0;
}
\end{langPyTwo}
\begin{langPyOne}[java]{Java语言代码排版(langPyOne环境)}
public class HelloWorld {
public static void main(String[] args){
System.out.println("Hello World!");
}
}
\end{langPyOne}
\langPyfile[c]{C语言代码排版(langPyfile命令)}{testc.c}
用\qtmark{langCVOne}环境可以实现交叉引用,如代码\ref{ccode01}所示。
\begin{langCVOne}[python][ccode01][Python]{Python(langCVOne环境)}
# -*- coding: UTF-8 -*-
# Filename : helloworld.py
# 该实例输出 Hello World!
print('Hello World!')
\end{langCVOne}
用\qtmark{\textbackslash langCVfile}命令可以实现交叉引用,如代码\ref{ccode02}所示。
\langCVfile[matlab][ccode02][Matlab]{Matlab(langCVfile命令)}{testm.m}
\section{注意事项}
\subsection{字体}
本宏包需要使用fontawesome5图标字体支持,请在
\url{https://fontawesome.com/}下载安装。
\subsection{代码排版引擎}
本宏包建议使用\qtmark{minted}宏包实现代码的排版,用\qtmark{xelatex
--shell-escape main.tex}编译tex文件,但如果没有安装minted
需要的python及其pygments模块,请提前安装该模块。
若在编译是不使用\qtmark{--shell-escape}参数,则会自动切换到用listings
排版代码,注意有部分代码名称与pygments定义不一致,请自行查阅相关手册。
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: