-
Notifications
You must be signed in to change notification settings - Fork 1
/
jlisting.sty
216 lines (203 loc) · 6.16 KB
/
jlisting.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
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
\NeedsTeXFormat{LaTeX2e}
\def\filedate{2006/02/20}
\def\fileversion{0.2}
\ProvidesPackage{jlisting}[\filedate\space\fileversion\space(Thor)]
%
\newcount\lst@nextchar
\let\lst@@ProcessSpace\lst@ProcessSpace
\def\lst@ProcessSpace#1{%
\lst@check@chartype{#1}%
\lst@@ProcessSpace
\lst@whitespacetrue}
\let\lst@@ProcessLetter\lst@ProcessLetter
\def\lst@ProcessLetter#1#2{%
\lst@check@chartype{#2}%
{\lst@@ProcessLetter{#1}}%
\relax}
\let\lst@@ProcessDigit\lst@ProcessDigit
\def\lst@ProcessDigit#1#2{%
\lst@check@chartype{#2}%
{\lst@@ProcessDigit{#1}}%
\relax}
\let\lst@@ProcessOther\lst@ProcessOther
\def\lst@ProcessOther#1#2{%
\lst@check@chartype{#2}%
{\lst@@ProcessOther{#1}}%
\relax}
\let\lst@@ProcessTabulator\lst@ProcessTabulator
\def\lst@ProcessTabulator#1{%
\lst@check@chartype{#1}%
\lst@@ProcessTabulator
\relax}
\def\lst@check@chartype#1#2#3{%
\edef\@tempa{\lst@nextchar=`\string#1\relax}%
\afterassignment\remove@to@nnil
\@tempa\@nnil
#2%
\ifnum\lst@nextchar<\@cclvi
#3%
\else
\lst@ifletter \else \lst@OutputOther \fi
\lst@whitespacefalse
\expandafter\lst@AppendJchar
\fi
#1}
\def\lst@AppendJchar#1#2{%
\lst@check@chartype{#2}%
{\advance\lst@length\@ne\lst@Append{#1}}%
\relax}
\def\lst@check@chartype@BOL#1{%
\edef\@tempa{\lst@nextchar=`\string#1\relax}%
\afterassignment\remove@to@nnil
\@tempa\@nnil
\ifnum\lst@nextchar<\@cclvi\else
\lst@whitespacefalse
\expandafter\lst@AppendJchar
\fi
#1}
\def\lst@InputListing#1{%
\begingroup
\lsthk@PreSet \gdef\lst@intname{#1}%
\expandafter\lstset\expandafter{\lst@set}%
\lsthk@DisplayStyle
\catcode\active=\active
\lst@Init\relax \let\lst@gobble\z@
\lst@SkipToFirst
\lst@ifprint \def\lst@next{\lst@get@filecontents{#1}}%
\else \let\lst@next\@empty
\fi
\lst@next
\lst@DeInit
\endgroup}
\newread\lst@inputfile
\def\lst@get@filecontents#1{%
\let\lst@filecontents\@empty
\openin\lst@inputfile=#1\relax
\let\@lst@get@filecontents@prevline\relax
\lst@get@filecontents@loop
\closein\lst@inputfile
\lst@filecontents\empty}
\def\lst@get@filecontents@loop{%
\read\lst@inputfile to\@lst@get@filecontents@currline
\ifx\@lst@get@filecontents@prevline\relax\else
\expandafter\expandafter\expandafter\def
\expandafter\expandafter\expandafter\lst@filecontents
\expandafter\expandafter\expandafter{%
\expandafter\lst@filecontents\@lst@get@filecontents@prevline}%
\fi
\let\@lst@get@filecontents@prevline\@lst@get@filecontents@currline
\ifeof\lst@inputfile\else
\expandafter\lst@get@filecontents@loop
\fi}
%%% [この処理も,相当強引です.]
\def\lst@BOLGobble{%
\ifnum\lst@gobble>\z@
\@tempcnta\lst@gobble\relax
\expandafter\lst@BOLGobble@
\else
\expandafter\lst@check@chartype@BOL
\fi}
\def\lst@BOLGobble@#1{%
\let\lst@next#1%
\ifx \lst@next\relax\else
\ifx \lst@next\lst@MProcessListing\else
\ifx \lst@next\lst@ProcessFormFeed\else
\ifx \lst@next\lstenv@backslash
\let\lst@next\lstenv@BOLGobble@@
\else
\let\lst@next\lst@BOLGobble@@
\ifx #1\lst@ProcessTabulator
\advance\@tempcnta-\lst@tabsize\relax
\ifnum\@tempcnta<\z@
\lst@length-\@tempcnta \lst@PreGotoTabStop
\fi
\else
\edef\@tempa{\lst@nextchar=`\string#1\relax}%
\@tempa
\ifnum\lst@nextchar<\@cclvi\else
\advance\@tempcnta\m@ne
\fi
\advance\@tempcnta\m@ne
\fi
\fi \fi \fi \fi
\lst@next}
\def\lst@BOLGobble@@{%
\ifnum\@tempcnta>\z@
\expandafter\lst@BOLGobble@
\else
\expandafter\lst@check@chartype@BOL
\fi
}
%
% \begin{修正事項}{1.3}
% ちょっとした修正
\gdef\lst@breakProcessOther#1{\lst@ProcessOther#1}
% ソースコード目次における文字と番号の空き
\let \l@lstlisting = \l@figure
% キャプションとソースコード目次に対する日本語対応
\def\lstlistingname{ソースコード}
\def\lstlistlistingname{ソースコード目次}
% \end{修正事項}
\endinput
%
%#!platex
\documentclass[papersize]{jsarticle}
% Macros
\IfFileExists{dvipdfmx.def}{%
\usepackage[dvipdfmx]{color,graphicx}%
}{%
\usepackage[dvipdfm]{color,graphicx}%
}
\usepackage{listings}[2004/09/07]
\usepackage{jlisting}[2006/02/20]
\usepackage{url}
\usepackage{verbatim}
\makeatletter
% Original Macros
\def\email#1{\gdef\@email{\texttt{#1}}}
\def\homepage#1{\gdef\@homepage{\texttt{#1}}}
\def\mac#1{\textsf{#1}}
\def\URL#1{\texttt{#1}}
\def\src#1{\texttt{#1}}
% Dvipdfmx.def
\def\dvipdfmxDefi{http://tex.dante.jp/ok/dvipdfmx/}
\def\dvipdfmxDefii{http://ftp.ktug.or.kr/KTUG/dvipdfmx/contrib/latex/}
\IfFileExists{dvipdfmx.def}{%
\let \IfDvipdfmxDef = \empty \relax}{%
\typeout{^^Jget dvipdfmx.def at \dvipdfmxDefi^^J
or \dvipdfmxDefii^^J}%
\def\IfDvipdfmxDef{Get \src{dvipdfmx.def} at \URL \dvipdfmxDefii \\
or \URL \dvipdfmxDefi.}%
}
% Author Info
\author {Th\'or Watanabe\thanks \@email \space \thanks \@homepage}
\title {\mac{jlisting.sty}\\
---Japanese Localized Patch File of \mac{listings}---}
\email {[email protected]}
\homepage {http://tex.dante.jp/typo/}
\date {2006/02/20}
\makeatother
\begin{document}
\maketitle
%\IfDvipdfmxDef
\section{ちょっとした説明}% Short Description
奥村晴彦氏の掲示板の「汎用的な浮動体」という一連の書き込みから
転載しました。
\begin{quote}
\url{http://http://cise.edu.mie-u.ac.jp/~okumura/texfaq/qa/21172.html}\\
\url{http://http://cise.edu.mie-u.ac.jp/~okumura/texfaq/qa/21184.html}\\
\url{http://http://cise.edu.mie-u.ac.jp/~okumura/texfaq/qa/21189.html}\\
\url{http://http://cise.edu.mie-u.ac.jp/~okumura/texfaq/qa/21197.html}
\end{quote}
Copyright は吉永哲美氏にあるのだと思います.
\section{更新履歴}% ChageLogs
\begin{description}
\item[ver.~0.1 (2004/03/24)]
とりあえず公開.
\item[ver.~0.2 (2006/02/20)]
\verb|\lst@breakProcessOther| 命令の定義の追加.
\end{description}
\section{ソースコード}
\par\narrowbaselines
\verbatiminput{jlisting.sty}
\end{document}