-
Notifications
You must be signed in to change notification settings - Fork 3
/
scala_text.tex
165 lines (137 loc) · 4.09 KB
/
scala_text.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
\documentclass[10pt, a4paper, oneside]{ltjsbook}
\usepackage{amssymb,amsmath}
\usepackage{fontspec}
\usepackage[Lenny]{fncychap}
\makeatletter
\renewcommand{\DOCH}{%
\settowidth{\px}{\CNV\FmN{\@chapapp}}
\addtolength{\px}{2pt}
\settoheight{\py}{\CNV\FmN{\@chapapp}}
\addtolength{\py}{1pt}
\settowidth{\mylen}{\CNV\FmN{\@chapapp}\space\CNoV\thechapter}
\addtolength{\mylen}{1pt}
\settowidth{\pxx}{\CNoV\thechapter}
\addtolength{\pxx}{-1pt}
\settoheight{\pyy}{\CNoV\thechapter}
\addtolength{\pyy}{-2pt}
\setlength{\myhi}{\pyy}
\addtolength{\myhi}{-1\py}
\par
\parbox[b]{\textwidth}{%
\rule[\py]{\RW}{\myhi}%
\hskip -\RW%
\rule[\pyy]{\px}{\RW}%
\hskip -\px%
\raggedright%
\CNV\FmN{\@chapapp}\space\CNoV\thechapter\CNV\FmN{\@chappos}%
\hskip1pt%
\mghrulefill{\RW}%
\rule{\RW}{\pyy}\par\nobreak%
\vskip -\baselineskip%
\vskip -\pyy%
\hskip \mylen%
\mghrulefill{\RW}\par\nobreak%
\vskip \pyy}%
\vskip 20\p@}
\makeatother
\usepackage{luacode}
\begin{luacode*}
USE_IPAFONT = os.getenv"USE_IPAFONT"
USE_YUFONT = os.getenv"USE_YUFONT"
if USE_YUFONT == "true" then
tex.sprint("\\AtBeginDocument{\\usepackage[yu-osx, deluxe, expert]{luatexja-preset}}")
elseif USE_IPAFONT == "true" then
tex.sprint("\\AtBeginDocument{\\usepackage[ipaex, deluxe, expert]{luatexja-preset}}")
else
tex.sprint("\\AtBeginDocument{\\usepackage[hiragino-pro, deluxe, expert]{luatexja-preset}}")
end
\end{luacode*}
\usepackage[centering]{geometry}
\usepackage[%
unicode=true,
breaklinks=true
bookmarks=true,
colorlinks=true,
pdfborder={0 0 0},
bookmarksnumbered=true,
bookmarkstype=toc,
bookmarksopen=true,
pdfauthor={株式会社ドワンゴ},
pdftitle={Scala Text}]{hyperref}
\usepackage{xcolor}
\usepackage{fancyvrb}
\usepackage{mdframed}
\usepackage{listings}
\input{listings_setting.tex}
\usepackage{longtable,booktabs}
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>.8\linewidth\linewidth\else\Gin@nat@width\fi}
\makeatother
\setkeys{Gin}{width=\maxwidth, keepaspectratio}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\usepackage{ifthen}
\LetLtxMacro\latexincludegraphics\includegraphics
\makeatletter
\renewcommand\includegraphics[2][]{%
\def\detectFileSvgOrNot[##1]##2.##3\nil{%
\ifthenelse{\equal{##3}{svg}}
{\input{##2.pdf_tex}}
{\latexincludegraphics[#1]{#2}}%
}%
\IfFileExists{#2}
{%
\filename@parse{#2}
\ifthenelse{\equal{\filename@ext}{svg}}
{\input{\[email protected]_tex}}
{\latexincludegraphics[#1]{#2}}}
{%
\fbox{Image File doesn't exist}%
\message{Image File #2 doesn't exist^^J}}
}
\makeatother
% Pandocの画像を適切に表示させるため
\setkeys{Gin}{keepaspectratio}
\begin{document}
\begin{luacode*}
require("lualibs-util-jsn.lua")
local target = "./target/"
local bookJsonFile = "book.json"
function read(file)
local handler = io.open(file, "rb")
local content = handler:read("*all")
handler:close()
return content
end
function readSummary(file)
local handler = io.open(file, "r")
local summary = {}
for l in handler:lines() do
local n = string.match(l, "%[.*%]%((.*)%.md%)")
table.insert(summary, n)
end
handler:close()
return summary
end
function getTeXFile(target, name)
return target .. name .. ".tex"
end
function getFileName(f)
return string.match(f, "(.*)%.md")
end
local bookJson = utilities.json.tolua(read(bookJsonFile))
local readmeFile = getTeXFile(target, getFileName(bookJson['structure']['readme']))
local summaryFile = target .. bookJson['structure']['summary']
tex.print("\\frontmatter")
tex.print("\\setcounter{secnumdepth}{0}")
tex.print("\\input{" .. readmeFile .. "}")
tex.print("\\tableofcontents")
tex.print("\\mainmatter")
tex.print("\\setcounter{secnumdepth}{3}")
for k, v in pairs(readSummary(summaryFile)) do
tex.print("\\input{" .. getTeXFile(target, v) .. "}")
end
\end{luacode*}
\end{document}