hiki2latex 0.9.12 → 0.9.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +1 -3
- data/{README.en.md → README.md} +6 -4
- data/Rakefile +56 -28
- data/exe/#hiki2latex# +5 -0
- data/hiki2latex.gemspec +3 -0
- data/hiki2latex.wiki/AbstSample.pdf +0 -0
- data/hiki2latex.wiki/Math.png +0 -0
- data/hiki2latex.wiki/Report_head.png +0 -0
- data/hiki2latex.wiki/handout_sample.md +73 -0
- data/{docs/README.ja.md → hiki2latex.wiki/hiki2latex.md} +14 -16
- data/hiki2latex.wiki/hiki2latex_gemizing.md +221 -0
- data/hiki2latex.wiki/hiki2latex_init.md +97 -0
- data/hiki2latex.wiki/hiki2latex_listings.md +113 -0
- data/hiki2latex.wiki/hiki2latex_manual.md +31 -0
- data/hiki2latex.wiki/hiki2latex_math.md +147 -0
- data/hiki2latex.wiki/hiki2latex_table.md +103 -0
- data/hiki2latex.wiki/lpso_abst.pdf +0 -0
- data/hiki2latex.wiki/readme_en.md +60 -0
- data/{README.ja.md → hiki2latex.wiki/readme_ja.md} +46 -26
- data/hiki2latex.wiki/table.png +0 -0
- data/hikis/AbstSample.pdf +0 -0
- data/hikis/Math.png +0 -0
- data/hikis/Report_head.png +0 -0
- data/{docs/readme.ja.hiki → hikis/hiki2latex.hiki} +4 -6
- data/hikis/hiki2latex_gemizing.hiki +222 -0
- data/hikis/hiki2latex_init.hiki +95 -0
- data/hikis/hiki2latex_listings.hiki +113 -0
- data/hikis/hiki2latex_manual.hiki +32 -0
- data/hikis/hiki2latex_math.hiki +145 -0
- data/hikis/hiki2latex_table.hiki +102 -0
- data/hikis/lpso_abst.pdf +0 -0
- data/{docs/readme.hiki → hikis/readme_en.hiki} +2 -0
- data/hikis/readme_ja.hiki +133 -0
- data/hikis/table.png +0 -0
- data/latexes/AbstSample.pdf +0 -0
- data/latexes/Math.png +0 -0
- data/latexes/Report_head.png +0 -0
- data/latexes/head.tex +4 -0
- data/latexes/hiki2latex.aux +60 -0
- data/latexes/hiki2latex.log +307 -0
- data/latexes/hiki2latex.pdf +0 -0
- data/latexes/hiki2latex.synctex.gz +0 -0
- data/latexes/hiki2latex.tex +213 -0
- data/latexes/hiki2latex.toc +47 -0
- data/latexes/hiki2latex_gemizing.tex +212 -0
- data/latexes/hiki2latex_init.tex +103 -0
- data/latexes/hiki2latex_listings.tex +106 -0
- data/latexes/hiki2latex_manual.tex +38 -0
- data/latexes/hiki2latex_math.tex +151 -0
- data/latexes/hiki2latex_table.tex +108 -0
- data/latexes/lpso_abst.pdf +0 -0
- data/latexes/post.tex +17 -0
- data/latexes/table.png +0 -0
- data/lib/#hiki2latex.rb# +145 -0
- data/lib/hiki2latex/hiki2latex.rb +2 -1
- data/lib/hiki2latex/version.rb +1 -1
- data/lib/hiki2latex.rb +2 -2
- metadata +84 -13
- data/#Rakefile# +0 -42
- data/#hiki2latex.gemspec# +0 -42
- data/{docs/README.en.md → hiki2latex.wiki/readme.md} +4 -4
@@ -0,0 +1,213 @@
|
|
1
|
+
\documentclass[10pt,a4jpaper]{jsarticle}
|
2
|
+
\usepackage[dvipdfmx]{graphicx}
|
3
|
+
\usepackage[dvipdfmx]{color}
|
4
|
+
\usepackage{listings}
|
5
|
+
% to use japanese correctly, install jlistings.
|
6
|
+
\lstset{
|
7
|
+
basicstyle={\small\ttfamily},
|
8
|
+
identifierstyle={\small},
|
9
|
+
commentstyle={\small\itshape\color{red}},
|
10
|
+
keywordstyle={\small\bfseries\color{cyan}},
|
11
|
+
ndkeywordstyle={\small},
|
12
|
+
stringstyle={\small\color{blue}},
|
13
|
+
frame={tb},
|
14
|
+
breaklines=true,
|
15
|
+
numbers=left,
|
16
|
+
numberstyle={\scriptsize},
|
17
|
+
stepnumber=1,
|
18
|
+
numbersep=1zw,
|
19
|
+
xrightmargin=0zw,
|
20
|
+
xleftmargin=3zw,
|
21
|
+
lineskip=-0.5ex
|
22
|
+
}
|
23
|
+
\lstdefinestyle{customCsh}{
|
24
|
+
language={csh},
|
25
|
+
numbers=none,
|
26
|
+
}
|
27
|
+
\lstdefinestyle{customRuby}{
|
28
|
+
language={ruby},
|
29
|
+
numbers=left,
|
30
|
+
}
|
31
|
+
\lstdefinestyle{customTex}{
|
32
|
+
language={tex},
|
33
|
+
numbers=none,
|
34
|
+
}
|
35
|
+
\lstdefinestyle{customJava}{
|
36
|
+
language={java},
|
37
|
+
numbers=left,
|
38
|
+
}
|
39
|
+
\begin{document}
|
40
|
+
\title{hiki2latex}
|
41
|
+
\author{関西学院大学・理工学部・西谷滋人}
|
42
|
+
\date{\today}
|
43
|
+
\maketitle
|
44
|
+
|
45
|
+
\abstract{
|
46
|
+
hiki formatで書かれた文章を,latex formatに変換する
|
47
|
+
|
48
|
+
}
|
49
|
+
\tableofcontents
|
50
|
+
\section{【documents】}\begin{itemize}
|
51
|
+
\item \verb|http://rubygems.org/gems/hiki2latex|
|
52
|
+
\end{itemize}
|
53
|
+
\section{【使用法】}\begin{lstlisting}[style=customCsh]
|
54
|
+
Usage: hiki2latex [options] FILE
|
55
|
+
-v, --version show program Version.
|
56
|
+
-l, --level VALUE set Level for output section.
|
57
|
+
-p, --plain FILE make Plain document.
|
58
|
+
-b, --bare FILE make Bare document.
|
59
|
+
--head FILE put headers of maketitle file.
|
60
|
+
--pre FILE put preamble file.
|
61
|
+
--post FILE put post file.
|
62
|
+
--listings use listings.sty for preformat with style.
|
63
|
+
\end{lstlisting}\begin{itemize}
|
64
|
+
\item より詳細な使用法は,\verb|hiki2latex_gemizing|にある.
|
65
|
+
\item 西谷研の内部で利用するときに特化したマニュアルは\verb|こちら(hiki2latex_manual)|.
|
66
|
+
\end{itemize}
|
67
|
+
\subsection{sample}
|
68
|
+
幾つかのサンプルを以下に示す.
|
69
|
+
|
70
|
+
\begin{table}[htbp]\begin{center}
|
71
|
+
\caption{hiki2latexにより作成されたpdfファイトとその元ネタ.}
|
72
|
+
\begin{tabular}{lll}
|
73
|
+
\hline
|
74
|
+
ソース(hiki表示) &pdf(latex変換後) \\ \hline
|
75
|
+
\verb|Shunkuntype(https://github.com/daddygongon/shunkuntype/wiki/Shunkuntype_report)| &\verb|Shunkuntypeのレポート(https://github.com/daddygongon/shunkuntype/wiki/shunkun_report.pdf)| \\
|
76
|
+
\verb|LPSO15研究会の例(LPSO15_fall_meeting_abst)| &\verb|{{attach_anchor(LPSO_abst.pdf)}}| \\
|
77
|
+
\verb|中間発表hand out例(AbstSample)| &\verb|{{attach_anchor(AbstSample.pdf)}}| \\
|
78
|
+
\verb|使っているformat集(DocumentFormatter_format_examples)| \\
|
79
|
+
\hline
|
80
|
+
\end{tabular}
|
81
|
+
\label{default}
|
82
|
+
\end{center}\end{table}
|
83
|
+
%for inserting separate lines, use \hline, \cline{2-3} etc.
|
84
|
+
|
85
|
+
\section{【仕様】}\begin{enumerate}
|
86
|
+
\item hikdoc.rbにwrap
|
87
|
+
\item header部を独立して提供
|
88
|
+
\item author, titleはheadに手を加えて提供
|
89
|
+
\item 図はattach\_viewを変換
|
90
|
+
\item 表はそのまま表示\begin{enumerate}
|
91
|
+
\item tableのmulti対応
|
92
|
+
\end{enumerate}
|
93
|
+
\item captionはheaderで提供
|
94
|
+
\item citeは対応しない.
|
95
|
+
\item graph, tableは[h]で提供.
|
96
|
+
\end{enumerate}
|
97
|
+
\section{【具体的な使用例rakefile】}
|
98
|
+
具体的な使用例として\verb|Shunkuntype_report|を作成した時のRakefile.rbを示す.何度も書き直す時は,このようにして自動化すべき.
|
99
|
+
\begin{lstlisting}[style=customRuby]
|
100
|
+
task :shunkuntype do
|
101
|
+
dir = '~/Sites/nishitani0/Internal/data/text/'
|
102
|
+
targets =["Shunkuntype_manual","Shunkuntype_gemizing","TouchTyping_Coding"]
|
103
|
+
targets.each{|file|
|
104
|
+
p command= "rm -f #{file}.tex"
|
105
|
+
system command
|
106
|
+
p command= "hiki2latex -l 2 --listings -b #{dir}#{file} > #{file}.tex"
|
107
|
+
system command
|
108
|
+
}
|
109
|
+
file="Shunkuntype_report"
|
110
|
+
p command= "rm -f #{file}.tex"
|
111
|
+
# p command= "hiki2latex --listings --head head.tex --post post.tex -p #{dir}#{file} > #{file}.tex"
|
112
|
+
p command= "hiki2latex --listings --post post.tex -p #{dir}#{file} > #{file}.tex"
|
113
|
+
system command
|
114
|
+
|
115
|
+
p command = "open #{file}.tex"
|
116
|
+
system command
|
117
|
+
exit
|
118
|
+
end
|
119
|
+
\end{lstlisting}
|
120
|
+
本文(Shunkuntype\_report.tex)と付録(targets.texs)がある.付録は'-l 2 -b'によってsubsectionからのtitle levelにしてbare modeで作っている.post.texにpostで付け加えるtex部を指定して,appendixをつけている.
|
121
|
+
|
122
|
+
\section{【変更履歴,内容】}
|
123
|
+
変更履歴,内容を表に示す.15/8月期で基本開発.16/2月期にgem化.
|
124
|
+
|
125
|
+
\begin{table}[htbp]\begin{center}
|
126
|
+
\caption{変更履歴,内容}
|
127
|
+
\begin{tabular}{llll}
|
128
|
+
\hline
|
129
|
+
memo &date &hiki \\ \hline
|
130
|
+
hikidoc.rbからhiki2latex.rb &15/8/4 &\verb|hiki2latex_init| \\
|
131
|
+
hiki2latex.rbひな形作成 &15/8/5 \\
|
132
|
+
@fをStringIOからStringへ &15/8/5 \\
|
133
|
+
graph+caption &15/8/6 &\verb|LPSO15_fall_meeting_abst| \\
|
134
|
+
math &15/8/7 &\verb|hiki2latex_math| \\
|
135
|
+
table &15/8/8 &\verb|hiki2latex_table| \\
|
136
|
+
under\_score &15/8/11 &\verb|hiki2latex_math| \\
|
137
|
+
gem化 &16/2/13 &\verb|hiki2latex_gemizing| \\
|
138
|
+
listings &16/2/16 &\verb|hiki2latex_listings| \\
|
139
|
+
\hline
|
140
|
+
\end{tabular}
|
141
|
+
\label{default}
|
142
|
+
\end{center}\end{table}
|
143
|
+
%for inserting separate lines, use \hline, \cline{2-3} etc.
|
144
|
+
|
145
|
+
\section{【開発メモ】}
|
146
|
+
\subsection{制限事項}\begin{itemize}
|
147
|
+
\item title中へuriの埋め込みが未対応.\begin{itemize}
|
148
|
+
\item uriのverbがlatexのtitle内で使えないため.
|
149
|
+
\end{itemize}
|
150
|
+
\end{itemize}
|
151
|
+
\subsection{【 保留項目】}\begin{enumerate}
|
152
|
+
\item includegraphicsの自動提供\begin{enumerate}
|
153
|
+
\item hikiに置かれているgraphは劣化版なんでそれをいじるのはあまり筋がよろしくない.
|
154
|
+
\item epsならできるかも.hikiのattach\_viewでサイズをどういじっているか...
|
155
|
+
\end{enumerate}
|
156
|
+
\item underbar(\_)がlatexでは全て引っかかる.escapeする?-> 対応済み \verb|hiki2latex_math|\begin{enumerate}
|
157
|
+
\item snake表記はrubyではfile名や変数名に頻繁に使われるので対処が必要かも.
|
158
|
+
\end{enumerate}
|
159
|
+
\end{enumerate}
|
160
|
+
\subsection{【math】}
|
161
|
+
$$での変換がうまくいかない.
|
162
|
+
\begin{quote}\begin{verbatim}
|
163
|
+
hikiconf.rb
|
164
|
+
\end{verbatim}\end{quote}
|
165
|
+
での設定を
|
166
|
+
\begin{quote}\begin{verbatim}
|
167
|
+
#@style = 'default'
|
168
|
+
@style = 'math'
|
169
|
+
\end{verbatim}\end{quote}
|
170
|
+
としたらhikiからエラーは出なくなったが.まだまだ....
|
171
|
+
|
172
|
+
\subsection{【user def】}\begin{quote}\begin{verbatim}
|
173
|
+
\def\Vec#1{\mbox{\boldmath $#1$}}
|
174
|
+
\end{verbatim}\end{quote}
|
175
|
+
はpreambleに置くことが推奨されているが,実際は,使用するまでに定義すればいい.preambleをいじるようになるころには,latexについての十分な経験があると思われるので,hiki2latexではいじらない.ちょこっと必要ならhiki本文中に埋め込むべし.今の仕様では,
|
176
|
+
\begin{lstlisting}[style=customRuby]
|
177
|
+
def initialize(file_name)
|
178
|
+
@buf = ""
|
179
|
+
@buf << HEADER+"\n"
|
180
|
+
@buf << "\\begin{document}\n"
|
181
|
+
@buf << HikiDoc.to_latex(file_name)+"\n"
|
182
|
+
@buf << REFERENCE+"\n"
|
183
|
+
@buf << "\\end{document}\n"
|
184
|
+
end
|
185
|
+
|
186
|
+
def display
|
187
|
+
@buf
|
188
|
+
end
|
189
|
+
\end{lstlisting}
|
190
|
+
とするのが正しそうなので,無理に入れていない.将来はpreambleを保持するような拡張機能(option)が必要かもしれない.それは,「原典一つ主義」で,hikiを原典とするか,latexを原典とするかの選択が迫られたとき.
|
191
|
+
\begin{itemize}
|
192
|
+
\item\begin{itemize}
|
193
|
+
\item 追記(2015/02/17) いい考察だ.解はでてないが今はhiki2latexに埋め込んで,それらの仕様をできるだけ吸収しようとしている.
|
194
|
+
\end{itemize}
|
195
|
+
\end{itemize}
|
196
|
+
\appendix
|
197
|
+
\section{詳細な使用法}
|
198
|
+
\input{hiki2latex_gemizing}
|
199
|
+
\pagebreak
|
200
|
+
\section{コード内容}
|
201
|
+
\subsection{起動}
|
202
|
+
\input{hiki2latex_init}
|
203
|
+
\pagebreak
|
204
|
+
\subsection{math環境}
|
205
|
+
\input{hiki2latex_math}
|
206
|
+
\pagebreak
|
207
|
+
\subsection{table環境}
|
208
|
+
\input{hiki2latex_table}
|
209
|
+
\pagebreak
|
210
|
+
\subsection{source code環境}
|
211
|
+
\input{hiki2latex_listings}
|
212
|
+
\pagebreak
|
213
|
+
\end{document}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
\contentsline {section}{\numberline {1}【documents】}{1}
|
2
|
+
\contentsline {section}{\numberline {2}【使用法】}{1}
|
3
|
+
\contentsline {subsection}{\numberline {2.1}sample}{2}
|
4
|
+
\contentsline {section}{\numberline {3}【仕様】}{2}
|
5
|
+
\contentsline {section}{\numberline {4}【具体的な使用例rakefile】}{2}
|
6
|
+
\contentsline {section}{\numberline {5}【変更履歴,内容】}{3}
|
7
|
+
\contentsline {section}{\numberline {6}【開発メモ】}{3}
|
8
|
+
\contentsline {subsection}{\numberline {6.1}制限事項}{3}
|
9
|
+
\contentsline {subsection}{\numberline {6.2}【 保留項目】}{4}
|
10
|
+
\contentsline {subsection}{\numberline {6.3}【math】}{4}
|
11
|
+
\contentsline {subsection}{\numberline {6.4}【user def】}{4}
|
12
|
+
\contentsline {section}{\numberline {付録A}詳細な使用法}{4}
|
13
|
+
\contentsline {subsubsection}{\numberline {A.0.1}【概要】}{4}
|
14
|
+
\contentsline {subsubsection}{\numberline {A.0.2}【使用法】}{5}
|
15
|
+
\contentsline {subsubsection}{\numberline {A.0.3}【help】}{5}
|
16
|
+
\contentsline {subsubsection}{\numberline {A.0.4}【詳細使用例(-p)】}{5}
|
17
|
+
\contentsline {subsubsection}{\numberline {A.0.5}【詳細使用例(-b)】}{6}
|
18
|
+
\contentsline {subsubsection}{\numberline {A.0.6}【詳細使用例( --head, --pre, --post】}{6}
|
19
|
+
\contentsline {subsubsection}{\numberline {A.0.7}【lib/hiki2latex.rb】}{7}
|
20
|
+
\contentsline {paragraph}{kill\_head\_line}{8}
|
21
|
+
\contentsline {paragraph}{mod\_abstract}{8}
|
22
|
+
\contentsline {section}{\numberline {付録B}コード内容}{9}
|
23
|
+
\contentsline {subsection}{\numberline {B.1}起動}{9}
|
24
|
+
\contentsline {subsubsection}{\numberline {B.1.1}【変更作業の手順】}{9}
|
25
|
+
\contentsline {subsubsection}{\numberline {B.1.2}【設計】}{9}
|
26
|
+
\contentsline {paragraph}{【maketitleの挿入】}{9}
|
27
|
+
\contentsline {subsubsection}{\numberline {B.1.3}【sample】}{10}
|
28
|
+
\contentsline {subsubsection}{\numberline {B.1.4}【pdfの貼り込み】}{10}
|
29
|
+
\contentsline {subsection}{\numberline {B.2}math環境}{11}
|
30
|
+
\contentsline {subsubsection}{\numberline {B.2.1}【概要】}{11}
|
31
|
+
\contentsline {subsubsection}{\numberline {B.2.2}【入力:hiki】}{11}
|
32
|
+
\contentsline {subsubsection}{\numberline {B.2.3}【出力:latex】}{11}
|
33
|
+
\contentsline {subsubsection}{\numberline {B.2.4}【コード解説】}{11}
|
34
|
+
\contentsline {paragraph}{evaluate\_plugin\_block}{11}
|
35
|
+
\contentsline {paragraph}{snake\_nameがlatexで引っかかる}{12}
|
36
|
+
\contentsline {paragraph}{escape\_snake\_namesを改良(2016/02/14)}{13}
|
37
|
+
\contentsline {paragraph}{escape\_snake\_namesを再改良(2016/02/16)}{13}
|
38
|
+
\contentsline {subsubsection}{\numberline {B.2.5}【copyright】}{13}
|
39
|
+
\contentsline {subsection}{\numberline {B.3}table環境}{14}
|
40
|
+
\contentsline {subsubsection}{\numberline {B.3.1}【概要】}{14}
|
41
|
+
\contentsline {subsubsection}{\numberline {B.3.2}【仕様】}{14}
|
42
|
+
\contentsline {subsubsection}{\numberline {B.3.3}【hiki】}{14}
|
43
|
+
\contentsline {subsubsection}{\numberline {B.3.4}【latex】}{14}
|
44
|
+
\contentsline {subsubsection}{\numberline {B.3.5}【コード解説】}{14}
|
45
|
+
\contentsline {subsection}{\numberline {B.4}source code環境}{17}
|
46
|
+
\contentsline {subsubsection}{\numberline {B.4.1}【概要】}{17}
|
47
|
+
\contentsline {subsubsection}{\numberline {B.4.2}【hiki2latexの変更】}{17}
|
@@ -0,0 +1,212 @@
|
|
1
|
+
|
2
|
+
\subsubsection{【概要】}
|
3
|
+
hikiフォーマットの記述をlatexフォーマットに変換する
|
4
|
+
|
5
|
+
\subsubsection{【使用法】}
|
6
|
+
gem化して配布可能とした.したがって,installがちゃんとできていれば,
|
7
|
+
\begin{description}
|
8
|
+
\item[command lineから]
|
9
|
+
|
10
|
+
\end{description}\begin{lstlisting}[style=customCsh]
|
11
|
+
bob% hiki2latex Shunkuntype_manual > tmp.tex
|
12
|
+
\end{lstlisting}\begin{description}
|
13
|
+
\item[libraryとして]
|
14
|
+
|
15
|
+
\end{description}\begin{lstlisting}[style=customRuby]
|
16
|
+
require 'hiki2latex'
|
17
|
+
|
18
|
+
puts HikiDoc.to_latex(File.read(ARGV[0]))
|
19
|
+
\end{lstlisting}\begin{lstlisting}[style=customCsh]
|
20
|
+
bob% ruby trans.rb ./Shunkuntype_manual > tmp.tex
|
21
|
+
\end{lstlisting}
|
22
|
+
などとして利用できる.
|
23
|
+
|
24
|
+
\subsubsection{【help】}\begin{lstlisting}[style=customCsh]
|
25
|
+
bob% hiki2latex
|
26
|
+
Usage: hiki2latex [options]
|
27
|
+
-v, --version show program Version.
|
28
|
+
-l, --level VALUE set Level for output section.
|
29
|
+
-p, --plain FILE make Plain document.
|
30
|
+
-b, --bare FILE make Bare document.
|
31
|
+
--head FILE put headers of maketitle file.
|
32
|
+
--pre FILE put preamble file.
|
33
|
+
--post FILE put post file.
|
34
|
+
\end{lstlisting}
|
35
|
+
\subsubsection{【詳細使用例(-p)】}
|
36
|
+
以下のようなSampleDoc
|
37
|
+
\begin{lstlisting}[style=]
|
38
|
+
bob% cat SampleDoc
|
39
|
+
!title
|
40
|
+
contents
|
41
|
+
*list1
|
42
|
+
*list2
|
43
|
+
!!title2
|
44
|
+
\end{lstlisting}
|
45
|
+
を
|
46
|
+
\begin{lstlisting}[style=customTeX]
|
47
|
+
bob% hiki2latex -p SampleDoc
|
48
|
+
\documentclass[12pt,a4paper]{jsarticle}
|
49
|
+
\usepackage[dvipdfmx]{graphicx}
|
50
|
+
\begin{document}
|
51
|
+
\section{title}
|
52
|
+
contents
|
53
|
+
\begin{itemize}
|
54
|
+
\item list1
|
55
|
+
\item list2
|
56
|
+
\end{itemize}
|
57
|
+
\subsection{title2}
|
58
|
+
\end{document}
|
59
|
+
\end{lstlisting}
|
60
|
+
となる.
|
61
|
+
|
62
|
+
\subsubsection{【詳細使用例(-b)】}
|
63
|
+
上記
|
64
|
+
\begin{lstlisting}[style=customTeX]
|
65
|
+
\begin{document}
|
66
|
+
...
|
67
|
+
\end{document}
|
68
|
+
\end{lstlisting}
|
69
|
+
の中身だけを生成.いくつものtex filesをincludeしている場合の個別ファイル作成に便利.
|
70
|
+
|
71
|
+
この際,'-l 2'として付録のsectionとかを調整する.
|
72
|
+
|
73
|
+
\subsubsection{【詳細使用例( --head, --pre, --post】}
|
74
|
+
formatを標準と違うものにするために,pre,head,postがある.詳しくはsampleを見よ.
|
75
|
+
していしていく順番はないはずだけど,-p SampleDocだけは順番があるのかな.
|
76
|
+
あと,erbみたいにして使ったほうがいいかも.
|
77
|
+
\begin{lstlisting}[style=customCsh]
|
78
|
+
bob% hiki2latex --pre preamble.tex --head head.tex --post post.tex -p SampleDoc
|
79
|
+
\end{lstlisting}\begin{lstlisting}[style=customTeX]
|
80
|
+
%preamble.tex
|
81
|
+
\documentclass[12pt,a4paper]{jsarticle}
|
82
|
+
\usepackage[dvipdfmx]{graphicx}
|
83
|
+
\pagestyle{empty}
|
84
|
+
\end{lstlisting}\begin{lstlisting}[style=customTeX]
|
85
|
+
\begin{document}
|
86
|
+
\end{lstlisting}\begin{lstlisting}[style=customTeX]
|
87
|
+
%head.tex
|
88
|
+
\author{関西学院大学・理工学部・西谷滋人}
|
89
|
+
\title{touch typing習得環境shunkuntype}
|
90
|
+
\date{\today}
|
91
|
+
\maketitle
|
92
|
+
\end{lstlisting}\begin{lstlisting}[style=customTeX]
|
93
|
+
\section{title}
|
94
|
+
contents
|
95
|
+
\begin{itemize}
|
96
|
+
\item list1
|
97
|
+
\item list2
|
98
|
+
\end{itemize}
|
99
|
+
\subsection{title2}
|
100
|
+
\end{lstlisting}\begin{lstlisting}[style=customTeX]
|
101
|
+
%post.tex
|
102
|
+
\pagebreak
|
103
|
+
\appendix
|
104
|
+
\section{マニュアル}
|
105
|
+
\input{shunkuntype_manual}
|
106
|
+
\pagebreak
|
107
|
+
\section{gem化メモ}
|
108
|
+
\input{shunkuntype_gemizing}
|
109
|
+
\pagebreak
|
110
|
+
\section{初期版のコード解説}
|
111
|
+
\input{shunkuntype_coding}
|
112
|
+
\end{lstlisting}\begin{lstlisting}[style=customTeX]
|
113
|
+
\end{document}
|
114
|
+
\end{lstlisting}
|
115
|
+
\subsubsection{【lib/hiki2latex.rb】}\begin{lstlisting}[style=customRuby]
|
116
|
+
require 'optparse'
|
117
|
+
require "hiki2latex/version"
|
118
|
+
#require "hiki2latex/hikidoc"
|
119
|
+
require "hiki2latex/hiki2latex"
|
120
|
+
|
121
|
+
module Hiki2latex
|
122
|
+
class Command
|
123
|
+
|
124
|
+
def self.run(argv=[])
|
125
|
+
new(argv).execute
|
126
|
+
end
|
127
|
+
|
128
|
+
def initialize(argv=[])
|
129
|
+
@argv = argv
|
130
|
+
@pre=@head=@post=nil
|
131
|
+
end
|
132
|
+
|
133
|
+
def execute
|
134
|
+
@argv << '--help' if @argv.size==0
|
135
|
+
command_parser = OptionParser.new do |opt|
|
136
|
+
opt.on('-v', '--version','show program Version.') { |v|
|
137
|
+
opt.version = Hiki2latex::VERSION
|
138
|
+
puts opt.ver
|
139
|
+
}
|
140
|
+
opt.on('-l VALUE','--level','set Level for output section.'){|level| @level=level.to_i}
|
141
|
+
opt.on('-p FILE', '--plain','make Plain document.') { |file| plain_doc(file) }
|
142
|
+
opt.on('-b FILE', '--bare','make Bare document.') { |file| bare_doc(file) }
|
143
|
+
opt.on('--head FILE', 'put headers of maketitle file.') { |file| @head=file }
|
144
|
+
opt.on('--pre FILE', 'put preamble file.') { |file| @pre=file }
|
145
|
+
opt.on('--post FILE', 'put post file.') { |file| @post=file }
|
146
|
+
opt.on('--listings', 'use listings.sty for preformat with style.') {@listings=true }
|
147
|
+
end
|
148
|
+
command_parser.banner = "Usage: hiki2latex [options] FILE"
|
149
|
+
command_parser.parse!(@argv)
|
150
|
+
plain_doc(@argv[0]) if @argv[0]!=nil
|
151
|
+
exit
|
152
|
+
end
|
153
|
+
|
154
|
+
# pre, post, listingsなどの拡張を処理
|
155
|
+
def plain_doc(file)
|
156
|
+
if @listings==true then
|
157
|
+
puts listings_preamble
|
158
|
+
elsif @pre==nil then
|
159
|
+
puts "\\documentclass[12pt,a4paper]{jsarticle}"
|
160
|
+
puts "\\usepackage[dvipdfmx]{graphicx}"
|
161
|
+
else
|
162
|
+
puts File.read(@pre)
|
163
|
+
end
|
164
|
+
puts "\\begin{document}"
|
165
|
+
puts File.read(@head) if @head!=nil
|
166
|
+
plain_tex = HikiDoc.to_latex(File.read(file),{:listings=>@listings})
|
167
|
+
puts mod_abstract(plain_tex)
|
168
|
+
puts File.read(@post) if @post!=nil
|
169
|
+
puts "\\end{document}"
|
170
|
+
end
|
171
|
+
|
172
|
+
def bare_doc(file)
|
173
|
+
bare_doc = HikiDoc.to_latex(File.read(file),{:level=>@level,:listings=>@listings})
|
174
|
+
puts kill_head_tableofcontents(bare_doc)
|
175
|
+
end
|
176
|
+
\end{lstlisting}
|
177
|
+
\paragraph{kill\_head\_line}
|
178
|
+
kill\_head\_lineで付録(bare\_text)にtocが含まれている場合は削除.
|
179
|
+
\begin{lstlisting}[style=customRuby]
|
180
|
+
def kill_head_tableofcontents(text)
|
181
|
+
text.gsub!(/^\\tableofcontents/,'')
|
182
|
+
end
|
183
|
+
\end{lstlisting}
|
184
|
+
\paragraph{mod\_abstract}
|
185
|
+
mod\_abstractで\verb|\section{abstract}|で書かれた内容をabstract環境へ移行する.一行づつの処理は有限状態マシン的に処理するのがいいらしい(Ruby Best Practice, p.112).一旦contentとabstractを分けて,その後,tableofcontentの前にabstractを挿入している.delete\_at(0)は一行目に\verb|\section{【abstract】}|が存在するため.
|
186
|
+
\begin{lstlisting}[style=customRuby]
|
187
|
+
# convert section to abstract
|
188
|
+
def mod_abstract(text)
|
189
|
+
abstract,section = [],[]
|
190
|
+
content = ""
|
191
|
+
text.split("\n").each do |line|
|
192
|
+
case line
|
193
|
+
when /^\\section(.+)/
|
194
|
+
section.push $1
|
195
|
+
end
|
196
|
+
|
197
|
+
case section[-1]
|
198
|
+
when /.+abstract.+/
|
199
|
+
abstract << line+"\n"
|
200
|
+
when /.+概要.+/
|
201
|
+
abstract << line+"\n"
|
202
|
+
else
|
203
|
+
content << line+"\n"
|
204
|
+
end
|
205
|
+
end
|
206
|
+
abstract.delete_at(0)
|
207
|
+
content.gsub!(/\\tableofcontents/){|text|
|
208
|
+
tt="\n\\abstract\{\n#{abstract.join}\}\n\\tableofcontents"
|
209
|
+
}
|
210
|
+
return content
|
211
|
+
end
|
212
|
+
\end{lstlisting}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
|
2
|
+
\subsubsection{【変更作業の手順】}\begin{itemize}
|
3
|
+
\item hikiをhtmlに変換するhikidoc.rbに加えていく形で変更
|
4
|
+
\item hikidocについて調べよ(澄田の宿題)
|
5
|
+
\end{itemize}\begin{lstlisting}[style=customRuby]
|
6
|
+
bob% diff hikidoc.rb master-hikidoc/lib/hikidoc.rb
|
7
|
+
39d38
|
8
|
+
< require './hiki2latex.rb'
|
9
|
+
58,61d56
|
10
|
+
< def HikiDoc.to_latex(src, options = {})
|
11
|
+
< new(LatexOutput.new(""), options).compile(src)
|
12
|
+
< end
|
13
|
+
<
|
14
|
+
916,917c911
|
15
|
+
< # puts HikiDoc.to_html(ARGF.read(nil))
|
16
|
+
< puts HikiDoc.to_latex(ARGF.read(nil))
|
17
|
+
---
|
18
|
+
> puts HikiDoc.to_html(ARGF.read(nil))
|
19
|
+
\end{lstlisting}\begin{itemize}
|
20
|
+
\item hiki2latex.rbに変更を加えていく.
|
21
|
+
\end{itemize}
|
22
|
+
\subsubsection{【設計】}
|
23
|
+
\paragraph{【maketitleの挿入】}
|
24
|
+
latex formatに仕込む際にテキストの順序が前後するコマンドが幾つかある.
|
25
|
+
\\maketitleの前に置かれた,
|
26
|
+
\begin{itemize}
|
27
|
+
\item title
|
28
|
+
\item author
|
29
|
+
\end{itemize}
|
30
|
+
である.これらはheadersとしてtext部と別に返すことも可能である.
|
31
|
+
具体的には,
|
32
|
+
|
33
|
+
\begin{table}[htbp]\begin{center}
|
34
|
+
\caption{}
|
35
|
+
\begin{tabular}{lll}
|
36
|
+
\hline
|
37
|
+
to\_html &*fを返す \\ \hline
|
38
|
+
to\_latex &*fと*headを返す. \\
|
39
|
+
\hline
|
40
|
+
\end{tabular}
|
41
|
+
\label{default}
|
42
|
+
\end{center}\end{table}
|
43
|
+
%for inserting separate lines, use \hline, \cline{2-3} etc.
|
44
|
+
|
45
|
+
なおto\_htmlとの互換性を維持するため*headを後に返すようにしている.
|
46
|
+
|
47
|
+
しかし,この部分は,to\_htmlとの整合性を考えるとto\_latexで処理してしまった方がよい.
|
48
|
+
そこで,
|
49
|
+
\begin{lstlisting}[style=customRuby]
|
50
|
+
def finish
|
51
|
+
@f.string
|
52
|
+
end
|
53
|
+
\end{lstlisting}
|
54
|
+
となっているのを,
|
55
|
+
\begin{lstlisting}[style=customRuby]
|
56
|
+
def finish
|
57
|
+
if @head != "" then
|
58
|
+
@head << "\\maketitle\n"
|
59
|
+
return @head+@f
|
60
|
+
else
|
61
|
+
return @f
|
62
|
+
end
|
63
|
+
end
|
64
|
+
\end{lstlisting}
|
65
|
+
とした.
|
66
|
+
|
67
|
+
\subsubsection{【sample】}\begin{itemize}
|
68
|
+
\item \verb|Jihou15|
|
69
|
+
\end{itemize}
|
70
|
+
\subsubsection{【pdfの貼り込み】}
|
71
|
+
pdfpagesを使おうとすると
|
72
|
+
\begin{quote}\begin{verbatim}
|
73
|
+
/usr/local/texlive/2015/texmf-dist/tex/latex/pdfpages/pdfpages.sty:70: LaTeX Er
|
74
|
+
ror: Missing \begin{document}.
|
75
|
+
|
76
|
+
See the LaTeX manual or LaTeX Companion for explanation.
|
77
|
+
Type H <return> for immediate help.
|
78
|
+
...
|
79
|
+
|
80
|
+
l.70 \input{pp\AM@driver.def}
|
81
|
+
\end{verbatim}\end{quote}
|
82
|
+
というエラーが出る.この解決法がわからず,incudegraphicsで対応.
|
83
|
+
\begin{quote}\begin{verbatim}
|
84
|
+
¥documentclass{jsarticle}
|
85
|
+
¥usepackage[dvipdfmx,hiresbb]{graphicx}
|
86
|
+
¥begin{document}
|
87
|
+
¥includegraphics[width=5cm]{sample.pdf}
|
88
|
+
¥end{document}
|
89
|
+
|
90
|
+
の4行目を
|
91
|
+
¥includegraphics[page=3,width=5cm]{sample.pdf}
|
92
|
+
とすれば、
|
93
|
+
|
94
|
+
普通に3ページ目の画像を使うことができました。
|
95
|
+
|
96
|
+
美文書5版のCD-ROMから普通にインストールした TeXShopの環境です。
|
97
|
+
|
98
|
+
つまり、何も(といっても、同書 P114 にあるように、
|
99
|
+
--shell--escape--commands=extractbb
|
100
|
+
をTeXShop環境設定の「内部設定」タブ pdfTex のLatexのオプションとして付け加えています。)特別なことをせずに、ページ指定をするだけで、できてしまいました。
|
101
|
+
|
102
|
+
次の、美文書の版には、ページ設定についても解説していただくといいかも知れません。>奥村先生お願いします。
|
103
|
+
\end{verbatim}\end{quote}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
\subsubsection{【概要】}
|
2
|
+
latexのlistingsスタイルを使って,source codeの色付き表示が可能に.
|
3
|
+
|
4
|
+
\subsubsection{【hiki2latexの変更】}
|
5
|
+
hikidoc2texで使われているのを参照して,
|
6
|
+
\begin{lstlisting}[style=customRuby]
|
7
|
+
def block_preformatted(str, info)
|
8
|
+
if (@listings==true and info!=nil) then
|
9
|
+
style='customRuby' if info=='ruby'
|
10
|
+
style='customCsh' if (info=='tcsh' or info=='csh')
|
11
|
+
style='customTeX' if info=='tex'
|
12
|
+
style='customJava' if info=='java'
|
13
|
+
preformatted_with_style(str,style)
|
14
|
+
else
|
15
|
+
preformatted(text(str))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def preformatted(str)
|
20
|
+
@f.slice!(-1)
|
21
|
+
@f << "\\begin{quote}\\begin{verbatim}\n"
|
22
|
+
@f << str+"\n"
|
23
|
+
@f << "\\end{verbatim}\\end{quote}\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def preformatted_with_style(str,style)
|
27
|
+
@f.slice!(-1)
|
28
|
+
@f << "\\begin{lstlisting}[style=#{style}]\n"
|
29
|
+
@f << str+"\n"
|
30
|
+
@f << "\\end{lstlisting}\n"
|
31
|
+
end
|
32
|
+
\end{lstlisting}
|
33
|
+
opt周りは,
|
34
|
+
\begin{lstlisting}[style=customRuby]
|
35
|
+
opt.on('--listings', 'use listings.sty for preformat with style.') {@listings=true }
|
36
|
+
\end{lstlisting}
|
37
|
+
としている.これをHikiDocへ渡す時は,
|
38
|
+
\begin{lstlisting}[style=customRuby]
|
39
|
+
def plain_doc(file)
|
40
|
+
if @listings==true then
|
41
|
+
puts listings_preamble
|
42
|
+
elsif @pre==nil then
|
43
|
+
puts "\\documentclass[12pt,a4paper]{jsarticle}"
|
44
|
+
puts "\\usepackage[dvipdfmx]{graphicx}"
|
45
|
+
else
|
46
|
+
puts File.read(@pre)
|
47
|
+
end
|
48
|
+
puts "\\begin{document}"
|
49
|
+
puts File.read(@head) if @head!=nil
|
50
|
+
puts HikiDoc.to_latex(File.read(file),{:listings=>@listings})
|
51
|
+
puts File.read(@post) if @post!=nil
|
52
|
+
puts "\\end{document}"
|
53
|
+
end
|
54
|
+
\end{lstlisting}
|
55
|
+
後ろのoptions={}の中にhashで登録している.texのstyleはlisting\_preambleで打ち出すようにしている.
|
56
|
+
|
57
|
+
listingsの設定は以下の通り.
|
58
|
+
\begin{lstlisting}[style=customTeX]
|
59
|
+
\documentclass[10pt,a4paper]{jsarticle}
|
60
|
+
\usepackage[dvipdfmx]{graphicx}
|
61
|
+
\usepackage[dvipdfmx]{color}
|
62
|
+
\usepackage{listings}
|
63
|
+
% to use japanese correctly, install jlistings.
|
64
|
+
\lstset{
|
65
|
+
basicstyle={\small\ttfamily},
|
66
|
+
identifierstyle={\small},
|
67
|
+
commentstyle={\small\itshape\color{red}},
|
68
|
+
keywordstyle={\small\bfseries\color{cyan}},
|
69
|
+
ndkeywordstyle={\small},
|
70
|
+
stringstyle={\small\color{blue}},
|
71
|
+
frame={tb},
|
72
|
+
breaklines=true,
|
73
|
+
numbers=left,
|
74
|
+
numberstyle={\scriptsize},
|
75
|
+
stepnumber=1,
|
76
|
+
numbersep=1zw,
|
77
|
+
xrightmargin=0zw,
|
78
|
+
xleftmargin=3zw,
|
79
|
+
lineskip=-0.5ex
|
80
|
+
}
|
81
|
+
\lstdefinestyle{customCsh}{
|
82
|
+
language={csh},
|
83
|
+
numbers=none,
|
84
|
+
}
|
85
|
+
\lstdefinestyle{customRuby}{
|
86
|
+
language={ruby},
|
87
|
+
numbers=left,
|
88
|
+
}
|
89
|
+
\lstdefinestyle{customTex}{
|
90
|
+
language={tex},
|
91
|
+
numbers=none,
|
92
|
+
}
|
93
|
+
\lstdefinestyle{customJava}{
|
94
|
+
language={java},
|
95
|
+
numbers=left,
|
96
|
+
}
|
97
|
+
\end{lstlisting}\begin{quote}\begin{verbatim}
|
98
|
+
\begin{lstlisting}[style=customRuby]
|
99
|
+
def block_preformatted(str, info)
|
100
|
+
if (@listings==true and info!=nil) then
|
101
|
+
style='customRuby' if info=='ruby'
|
102
|
+
style='customCsh' if (info=='tcsh' or info=='csh')
|
103
|
+
style='customTeX' if info=='tex'
|
104
|
+
...
|
105
|
+
\end{lstlisting}
|
106
|
+
\end{verbatim}\end{quote}
|