forked from le0pard/chef_book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chef.sty
157 lines (140 loc) · 3.85 KB
/
chef.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
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
\newif\ifpdf
\ifx\pdfoutput\undefined
\pdffalse
\else
\ifnum\pdfoutput=1
\pdftrue
\else
\pdffalse
\fi
\fi
\ProvidesPackage{chef}
\RequirePackage{cmap}
\RequirePackage{graphicx}
\RequirePackage{tabularx}
\RequirePackage{indentfirst}
\RequirePackage{mathtext}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage[english]{babel}
\RequirePackage{listings}
\RequirePackage[scaled]{beramono}
\RequirePackage{tgadventor}
\RequirePackage{times}
\RequirePackage[usenames,dvipsnames]{color}
\RequirePackage[colorlinks=true]{hyperref}
\RequirePackage{amssymb,amsmath,amsfonts}
\RequirePackage{perpage} %the perpage package
\RequirePackage{wrapfig}
\RequirePackage{pdfpages} % cover image
\RequirePackage{lmodern}
\RequirePackage{xcolor}
\RequirePackage[breakall]{truncate}
\ifpdf
\RequirePackage{pdfpages} % cover image
\fi
\graphicspath{{images/}{cover/}}
\renewcommand{\lstlistingname}{Code}% Listing -> Algorithm
\renewcommand{\lstlistlistingname}{Codes}
\sloppy
\definecolor{lineno}{rgb}{0.5,0.5,0.5}
\definecolor{code}{rgb}{0,0.1,0.6}
\definecolor{keyword}{rgb}{0.5,0.1,0.1}
\definecolor{titlebox}{rgb}{0.85,0.85,0.85}
\definecolor{download}{rgb}{0.8,0.1,0.5}
\definecolor{code_title}{rgb}{0.8,0.1,0.4}
\definecolor{title}{rgb}{0.2,0.2,0.2}
\definecolor{codered}{rgb}{0.6,0,0} % for strings
\definecolor{codegreen}{rgb}{0.25,0.5,0.35} % comments
\definecolor{codepurple}{rgb}{0.5,0,0.35} % keywords
\definecolor{codedocblue}{rgb}{0.25,0.35,0.75} % javadoc
\lstset{
language=Ruby,
%basicstyle=\ttfamily,
basicstyle=\footnotesize,
keywordstyle=\color{codepurple}\bfseries,
stringstyle=\color{codered},
commentstyle=\color{codegreen},
showspaces=false,
showstringspaces=false,
breaklines=true,
breakatwhitespace=false,
numbers=left,
firstnumber=1,
stepnumber=5,
numberfirstline=true,
numberstyle=\color{lineno}\sffamily\scriptsize,
keywordstyle=\color{keyword}\bfseries
}
\colorlet{punct}{red!60!black}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\lstdefinelanguage{JSON}{
literate=
*{0}{{{\color{numb}0}}}{1}
{1}{{{\color{numb}1}}}{1}
{2}{{{\color{numb}2}}}{1}
{3}{{{\color{numb}3}}}{1}
{4}{{{\color{numb}4}}}{1}
{5}{{{\color{numb}5}}}{1}
{6}{{{\color{numb}6}}}{1}
{7}{{{\color{numb}7}}}{1}
{8}{{{\color{numb}8}}}{1}
{9}{{{\color{numb}9}}}{1}
{:}{{{\color{punct}{:}}}}{1}
{,}{{{\color{punct}{,}}}}{1}
{\{}{{{\color{delim}{\{}}}}{1}
{\}}{{{\color{delim}{\}}}}}{1}
{[}{{{\color{delim}{[}}}}{1}
{]}{{{\color{delim}{]}}}}{1},
}
\def\inline{
\lstinline[
basicstyle=\ttfamily,
keywordstyle={},
breaklines=true
]
}
\makeatletter
\gdef\lst@SkipOrPrintLabel{%
\ifnum\lst@skipnumbers=\z@
\global\advance\lst@skipnumbers-\lst@stepnumber\relax
\lst@PlaceNumber
\lst@numberfirstlinefalse
\else
\lst@ifnumberfirstline
{\def\thelstnumber{Line \@arabic\c@lstnumber}\lst@PlaceNumber}%
\lst@numberfirstlinefalse
\else
{\def\thelstnumber{-}\lst@PlaceNumber}%
\fi
\fi
\global\advance\lst@skipnumbers\@ne}%
\def\lst@makecaption#1#2{
\vskip\abovecaptionskip
\colorbox{titlebox}{
%\scriptsize
\small
\color{code_title}\ttfamily#1
\color{title}\sffamily\bfseries#2}
\vskip\belowcaptionskip}
\def\lst@maketitle#1{
\vskip\abovecaptionskip
\colorbox{titlebox}{
%\scriptsize
\small
\color{download}\ttfamily\href{http://chef.leopard.in.ua/code/#1}{Download}
\color{title}\sffamily\bfseries\truncate{.85\textwidth}{#1}}
\vskip\belowcaptionskip}
\makeatother
\let\olditemize=\itemize
\def\itemize{
\olditemize
\setlength{\itemsep}{-1ex}
}
\let\oldenumerate=\enumerate
\def\enumerate{
\oldenumerate
\setlength{\itemsep}{-1ex}
}
\MakePerPage{footnote} %the perpage package command