OSDN Git Service

ae6189efac8f1b2949ad51dec50fe872dccb86db
[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
7 [
8         papersize={100mm,100mm},
9         hmargin={5mm,5mm},
10         vmargin={5mm,5mm}
11 ]{geometry}
12 \pagestyle{empty}
13
14 \lstset
15 {
16         language=sh, extendedchars=false,
17         backgroundcolor=\color[gray]{.75},
18         breaklines=true,
19     basewidth={0.55\zw, 0.45em},
20         numbers=left,numberstyle=\tiny, numbersep=2pt,
21 }
22
23 \lstnewenvironment{env}[1]
24 {
25         \ifx\relax#1\else
26         \renewcommand{\lstlistingname}{ex}
27         \lstset
28         {
29                 caption=#1,
30         }
31         \fi
32 }{}
33 \DeclareFontShape{JY3}{mc}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
34 \DeclareFontShape{JY3}{mc}{m}{it}{<-> ssub* mc/m/sl}{}
35
36 \setmainfont{TeX Gyre Pagella}
37 \setmonofont{TeX Gyre Cursor}
38 \begin{document}
39 This test file is based on a.tex\footnote{This can be downloaded from {\tt https://gist.github.com/1574793}.} by x19290.
40
41
42 \textbf{SOLVED}: bad folding and not slanted problems are common in pLaTeX and LuaTeX-ja.
43
44 The cause of the latter problem is that Japanese fonts don't have italic shape by default.
45 In this document, we define them by
46 \begin{lstlisting}[language={[AlLaTeX]TeX}, basicstyle=\ttfamily]
47 \DeclareFontShape{JY3}{mc}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
48 \DeclareFontShape{JY3}{mc}{m}{it}{<-> ssub* mc/m/sl}{}
49 \end{lstlisting}
50 \newpage
51
52 We also avoid white band problem, by setting both the height and the depth of each 
53 letter/word to 0\,pt. 
54
55 \begin{env}{\relax}
56 #!/bin/sh
57 #長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
58 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
59 #I.長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長いI
60 長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
61 #IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
62 IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
63 \end{env}
64
65 Note that any \emph{kinsoku shori} is not performed inside \textsf{lstlisting} environment,
66 as the line~3 in output above. We leave it to further development.
67 \newpage
68
69 \textbf{SOLVED}: LuaTeX-ja specific problem:
70 when the \emph{begin} line of a listings environment ends with JAchar,
71 the first line of the listing is not rendered.
72
73 \begin{env}{problem; shebang not rendered --- 問題}
74 #!/bin/bash
75 :
76 \end{env}
77
78 \begin{LTXexample}[language=TeX]
79 え!1あ,い・あ)う(え
80 え!2あ
81 \end{LTXexample}
82
83 \lstinputlisting{test13-listings.tmp}
84
85 \begin{lstlisting}
86 え!1あアイウエオ
87 え!2あ
88 \end{lstlisting}
89 \newpage
90 \textbf{Ticket \#29311}
91
92 \begin{env}{\relax}
93 長い長い長い長い長い長い長い長い長い長い長い長い#い長い
94 長い長い長い長い長い長い長い長い長い長い長い長aaaa#::い長い
95 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い
96 長い長い長い長い長い長い長い長い長い長い長い長aa,::い長い
97 長い長い長い長い長い長い長い長い長い長い長い長,,::い長い
98 長い長い長い長い長い長い長い長い長い長い長い長(い長い
99 長い長い長い長い長い長い長い長い長い長い長いaa(い長い
100 長い長い長い長い長い長い長い長い長い長い長い長(aa長い
101 長い長い長い長い長い長い長い長い長い長い長い長い)(長い
102 \end{env}
103
104 \newpage
105 \textbf{Ticket \#29604}
106
107 \ltjsetparameter{jacharrange={-2,-8}}
108 ギリシャ文字欧文扱い
109
110 \begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
111 01234567890123456789
112 !あ!漢!α!×!
113 \TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
114 \end{lstlisting}
115
116 \ltjsetparameter{jacharrange={+2,+8}}
117 ギリシャ文字和文扱い
118
119 \begin{lstlisting}[basewidth=.5em,basicstyle=\tt, emph={TeX}, emphstyle=\color{red}]
120 01234567890123456789
121 !あ!漢!α!×!
122 \TeX はギリシャ文字のΤ-Ε-Χ(タウ・イプシロン・カイ)であるから、……
123 \end{lstlisting}
124 \end{document}