OSDN Git Service

luatexja-fontspec.sty: Changed syntax of AltFont
[luatex-ja/luatexja.git] / test / test13-listings.tex
1 %#!lualatex
2 \documentclass{article}
3
4 \usepackage{luatexja-fontspec}
5 \usepackage{listings,color,showexpl}
6 \usepackage{luatexja-otf}
7 \directlua{luatexja.otf.enable_ivs()}
8 \usepackage
9 [
10         papersize={100mm,100mm},
11         hmargin={5mm,5mm},
12         vmargin={5mm,5mm}
13 ]{geometry}
14 \pagestyle{empty}
15
16 \lstset
17 {
18         language=sh, extendedchars=false,
19         backgroundcolor=\color[gray]{.75},
20         breaklines=true,
21         explpreset={columns=fixed},
22     basewidth={0.5\zw, 0.45em},
23         numbers=left,numberstyle=\tiny, numbersep=2pt,
24 }
25
26 \lstnewenvironment{env}[1]
27 {
28         \ifx\relax#1\else
29         \renewcommand{\lstlistingname}{ex}
30         \lstset
31         {
32                 caption=#1,
33         }
34         \fi
35 }{}
36 \DeclareKanjiFamily{JY3}{koz}{}
37 \DeclareFontShape{JY3}{koz}{m}{n}{<-> s * [0.92489] KozMinPr6N-Regular:jfm=ujis}{}
38 \DeclareFontShape{JY3}{koz}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
39 \DeclareFontShape{JY3}{koz}{m}{it}{<-> ssub* koz/m/sl}{}
40 \def\mcdefault{koz}
41
42 \setmainfont{TeX Gyre Pagella}
43 \setmonofont{TeX Gyre Cursor}
44 \begin{document}
45
46 This test file is based on a.tex\footnote{This can be downloaded from {\tt https://gist.github.com/1574793}.} by x19290.
47
48
49 \textbf{SOLVED}: bad folding and not slanted problems are common in pLaTeX and LuaTeX-ja.
50
51 The cause of the latter problem is that Japanese fonts don't have italic shape by default.
52 In this document, we define them by
53 \begin{lstlisting}[language={[AlLaTeX]TeX}, basicstyle=\ttfamily]
54 \DeclareFontShape{JY3}{mc}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
55 \DeclareFontShape{JY3}{mc}{m}{it}{<-> ssub* mc/m/sl}{}
56 \end{lstlisting}
57 \newpage
58
59 We also avoid white band problem, by setting both the height and the depth of each 
60 letter/word to 0\,pt. 
61
62 \begin{env}{\relax}
63 #!/bin/sh
64 #長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
65 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
66 #長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
67 #I.長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長いI
68 長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
69 #IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
70 IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
71 \end{env}
72
73 \newpage
74
75 \textbf{SOLVED}: LuaTeX-ja specific problem:
76 when the \emph{begin} line of a listings environment ends with JAchar,
77 the first line of the listing is not rendered.
78
79 \begin{env}{problem; shebang not rendered --- 問題}
80 #!/bin/bash
81 :
82 \end{env}
83
84 \begin{LTXexample}[language=TeX]
85 え!1あ,い・あ)う(え
86 え!2あ
87 \end{LTXexample}
88
89 \lstinputlisting{test13-listings.tmp}
90
91 \begin{lstlisting}
92 え!1あアイウエオ
93 え!2あ
94 \end{lstlisting}
95 \newpage
96 \textbf{Ticket \#29311}
97
98 \begin{env}{\relax}
99 長い長い長い長い長い長い長い長い長い長い長い長い#い長い
100 長い長い長い長い長い長い長い長い長い長い長い長aaaa#::い長い
101 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い
102 長い長い長い長い長い長い長い長い長い長い長い長aa,::い長い
103 長い長い長い長い長い長い長い長い長い長い長い長,,::い長い
104 長い長い長い長い長い長い長い長い長い長い長い長(い長い
105 長い長い長い長い長い長い長い長い長い長い長いaa(い長い
106 長い長い長い長い長い長い長い長い長い長い長い長(aa長い
107 長い長い長い長い長い長い長い長い長い長い長い長い)(長い
108 \end{env}
109
110 \newpage
111 \textbf{Ticket \#29604}
112
113 \setmonofont{DejaVu Sans Mono}
114 \ltjsetparameter{jacharrange={-2,-3,-8}}
115 ギリシャ文字欧文扱い
116
117 \begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
118 01234567890123456789
119 !あ!漢!α!×!
120 \TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
121 \TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē).
122 \end{lstlisting}
123
124 \ltjsetparameter{jacharrange={+2,+8,+3}}
125 ギリシャ文字和文扱い
126
127 \begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
128 01234567890123456789
129 !あ!漢!α!×!
130 \TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
131 \TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē).
132 \end{lstlisting}
133
134 \newpage
135 IVS対応1: \texttt{vsraw=false} (default)
136
137 \begin{LTXexample}[escapechar=\%, basicstyle=\tt]
138 1234567890
139 1葛󠄀城,葛󠄁飾
140 󠄀a
141 \end{LTXexample}
142
143 IVS対応2: \texttt{vsraw=true}
144
145 \begin{LTXexample}[escapechar=\%,vsraw, basicstyle=\tt]
146 1234567890
147 1葛󠄀城,葛󠄁飾アイウ
148 \end{LTXexample}
149
150 \begin{lstlisting}[escapechar=\%,vsraw, basewidth=1\zw, basicstyle=\tt]
151 1234567890
152 1あ,23
153 1あ2,3
154 \end{lstlisting}
155 \end{document}