2 \documentclass{article}
4 \usepackage{listings,color,showexpl,comment}
6 \usepackage{luatexja-fontspec,amsmath}
7 \usepackage{luatexja-otf}\directlua{luatexja.otf.enable_ivs()}
10 papersize={100mm,100mm},
18 language=sh, extendedchars=false,
19 backgroundcolor=\color[gray]{.75},
21 explpreset={columns=fixed},
22 basewidth={0.5\zw, 0.45em},
23 numbers=left,numberstyle=\tiny, numbersep=2pt,
26 \lstnewenvironment{env}[1]
29 \renewcommand{\lstlistingname}{ex}
36 \DeclareKanjiFamily{JY3}{koz}{}
37 \DeclareFontShape{JY3}{koz}{m}{n}{<-> s * [1.2] KozMinPr6N-Regular:jfm=ujis}{}
38 \DeclareFontShape{JY3}{koz}{m}{sl}{<-> s * [1.2] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
39 \DeclareFontShape{JY3}{koz}{m}{it}{<-> ssub* koz/m/sl}{}
42 \setmainfont{TeX Gyre Pagella}
43 \setmonofont{TeX Gyre Cursor}
44 \def\cs#1{\hbox{\texttt{\textbackslash #1}}}
47 This test file is based on a.tex\footnote{This can be downloaded from {\tt https://gist.github.com/1574793}.} by x19290.
50 \textbf{SOLVED}: bad folding and not slanted problems are common in pLaTeX and LuaTeX-ja.
52 The cause of the latter problem is that Japanese fonts don't have italic shape by default.
53 In this document, we define them by
54 \begin{lstlisting}[language={[AlLaTeX]TeX}, basicstyle=\ttfamily]
55 \DeclareFontShape{JY3}{mc}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
56 \DeclareFontShape{JY3}{mc}{m}{it}{<-> ssub* mc/m/sl}{}
60 We also avoid white band problem, by setting the value of \cs{lineskiplimit} to
62 -\min(\cs{cht}-\cs{ht}\cs{strutbox}, 0)\\
63 -\min(\cs{cdp}-\cs{dp}\cs{strutbox}, 0).
66 Note: we still have a white band if the first line is line-broken.
70 #長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
71 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
72 #長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
73 #I.長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長いI
74 長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
75 #IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
76 IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
81 \textbf{SOLVED}: LuaTeX-ja specific problem:
82 when the \emph{begin} line of a listings environment ends with JAchar,
83 the first line of the listing is not rendered.
85 \begin{env}{problem; shebang not rendered --- 問題}
90 \begin{LTXexample}[language=TeX]
95 \lstinputlisting{test13-listings.tmp}
102 \textbf{Ticket \#29311}
105 長い長い長い長い長い長い長い長い長い長い長い長aaa長い::い長い
106 長い長い長い長い長い長い長い長い長い長い長い長aaaa長い::い長い
107 長い長い長い長い長い長い長い長い長い長い長い長い長い,長い長い
108 あ長い長い長い長い長い長い長い長い長い長い長い長い長い,長い長い
109 長い長い長い長い長い長い長い長い長い長い長い長い長a,::い長い
110 長い長い長い長い長い長い長い長い長い長い長い長い長aa,::い長い
111 長い長い長い長い長い長い長い長い長い長い長い長い長aaa,::い長い
112 長い長い長い長い長い長い長い長い長い長い長い長い長aaaa,::い長い
113 長い長い長い長い長い長い長い長い長い長い長い長い長い,,::い長い
114 長い長い長い長い長い長い長い長い長い長い長い長(い長い
115 長い長い長い長い長い長い長い長い長い長い長いaa(い長い
116 長い長い長い長い長い長い長い長い長い長い長い長(aa長い
117 長い長い長い長い長い長い長い長い長い長い長い長い)(長い
118 あ長い長い長い長い長い長い長い長い長い長い長い長い)(長い
122 \textbf{Ticket \#29604}
124 \setmonofont{DejaVu Sans Mono}
125 \ltjsetparameter{jacharrange={-2,-3,-8}}
128 \begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
131 \TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
132 \TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē).
135 \ltjsetparameter{jacharrange={+2,+8,+3}}
138 \begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
141 \TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
142 \TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē).
146 IVS対応1: \texttt{vsraw=false} (default)
148 \begin{LTXexample}[escapechar=\%, basicstyle=\tt]
154 IVS対応2: \texttt{vsraw=true}
156 \begin{LTXexample}[escapechar=\%,vsraw, basicstyle=\tt]
163 下の行において,最初の「1」の場所がずれてしまうのは半ば仕方がないとも言える.
164 1行目では,「1234567890」が前後・文字間に計11箇所の等量の空白を入れて10全角の領域に
165 出力されているのに対し,2,~3行目では「1」が全角幅に左右中央で出力されているからである.
166 \begin{lstlisting}[escapechar=\%,vsraw, basewidth=1\zw, basicstyle=\tt]
173 \texttt{doubleletterspace}オプションを指定すると,出力単位中の文字と文字の間隔を2倍にするため,
174 下の例の「1」のように,各文字の垂直位置が揃いやすくなる.
175 \begin{lstlisting}[escapechar=\%,doubleletterspace, basewidth=1\zw, basicstyle=\tt]
185 \textbf{Ticket \#34786}
186 \ltjsetparameter{autoxspacing=false}
188 foo \lstinline[basicstyle=\tt]!ba{}#shr! baz あ
190 1あ\lstinline[basicstyle=\tt]{bar s}hoge
192 2あ\lstinline[basicstyle=\tt]{bar..{a}hoge
194 foo \lstinline[basicstyle=\tt\gtfamily]!exit 0; #shbar! baz あ
196 foo \lstinline[basicstyle=\tt\gtfamily]!あreturn 0; #shbar! baz あ
198 3あ\lstinline[basicstyle=\tt]{fexit #sh$ar}hoge
200 4あ\lstinline[basicstyle=\tt]{いbexit #sh$ar}hoge
203 \textbf{Ticket \#35484}
205 \colorbox{red}{\lstinline!aiu#sheoxyz!}
206 \colorbox{red}{\lstinline!あいexit 0;#shうえお!}
209 \colorbox{red}{\lstinline{aGiu#sheoxyz}}
210 \colorbox{red}{\lstinline{あGいexit 0;#shうえお}}
213 \begin{lstlisting}[frame=single]
219 \textbf{Escape character}
220 \begin{lstlisting}[escapechar=\#,basicstyle=\ttfamily]
222 aiu# \textcolor{red}{e} #o#\textcolor{red}{ka}#ki
227 \textbf{Ticket \#44426}\lstset{basicstyle=\itshape}
228 Foo ÷fo#shbarあ{#}o÷ Foo
229 \colorbox{green}{÷fo#shbarあ{#}o÷}
231 \lstMakeShortInline あ