forked from Timozer/CUGThesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcode.sty
80 lines (71 loc) · 2.58 KB
/
tcode.sty
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
% !TEX TS-program xelatex
% !TEX encoding = UTF-8 Unicode
% -*- coding: UTF-8; -*-
% vim: set fenc=utf-8
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FileName: tcode.sty
%% Author: Timozer
%% E-mail: zhenyuwang94@gmail.com
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{tcode}[2018/02/03 v0.6 Source Code Environment]
\RequirePackage[newfloat=true, cachedir=./_minted-cache, langlinenos=true]{minted}
% minted package options chapter, section,
\RequirePackage{xcolor}
\RequirePackage{xifthen}
%\RequirePackage{caption}
%\captionsetup{skip = 3pt, position=top, tableposition=top, figureposition=bottom}
%-------------- 伪代码环境 -----------------
%\newif\if@restonecol
%\let\algorithm\relax
%\let\endalgorithm\relax
%\RequirePackage[linesnumbered,ruled,vlined]{algorithm2e}%[ruled,vlined]{
%\RequirePackage{algpseudocode}
%\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
%\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm
%-------------------------------------------
\definecolor{mygray}{rgb}{0.85, 0.85, 0.85}
%%----------------- minted code settings -----------------
% \mintinline[opts]{lang}{code}
% \inputminted[opts]{lang}{code}
% \usemintedstyle[lang]{style}
%
% 查阅 caption fancyvrb mdframed tcolorbox etoolbox floatrow
% \theFancyVerbLine
% options: breakanywhere(doesn't apply to \mintedinline), breaklines, codetagify=(list of strings), escapeinside=(string), framesep=(dim), label=, style=, texcl(enable latex code inside comments), xrightmargin=(dim)
\setminted{%
baselinestretch=1, % 代码行间距
tabsize=4,
autogobble,
texcl,
mathescape,
frame=single,
framerule=0pt,
bgcolor=mygray,
numbersep=2pt,
xleftmargin=12pt,
fontsize=\small,
fontfamily=tt,
linenos,
numbers=left,
stepnumberfromfirst,
stepnumber=1,
numberblanklines,
breaklines,
breakanywhere,
}
% 在写文档时候用的一些选项: [options], firstline=, firstnumber=(auto|last|int), lastline=, highlightcolor=(color or name), highlightlines={1, 3-4}
%\beforebeginenvironment{minted}{\begin{mdframed}}
%\afterendenvironment{minted}{\end{mdframed}}
% \surroundwithmdframed{minted}
% define shortcuts
\setmintedinline{autogobble, breakanywhere, breaklines, linenos=false, fontsize=\small, fontfamily=tt, bgcolor={}}
\newcommand{\tcodeinline}[2]{%
\mintinline{#1}|#2|
}
% input file
% \newmintedfile[marconame]{lang}{opts}
% usage: \langfile
%-------------------------------------------
\endinput