OSDN Git Service

Updated Figure 2 in the manual.
[luatex-ja/luatexja.git] / test / test13-listings.tex
1 %#!lualatex
2 \documentclass{article}
3
4 \usepackage{luatexja}
5 \usepackage{palatino,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,
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 \begin{document}
36 This test file is based on a.tex\footnote{This can be downloaded from {\tt https://gist.github.com/1574793}.} by x19290.
37
38
39 \textbf{SOLVED}: bad folding and not slanted problems are common in pLaTeX and LuaTeX-ja.
40
41 The cause of the latter problem is that Japanese fonts don't have italic shape by default.
42 In this document, we define them by
43 \begin{lstlisting}[language={[AlLaTeX]TeX}, basicstyle=\ttfamily]
44 \DeclareFontShape{JY3}{mc}{m}{sl}{<-> s * [0.92489] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
45 \DeclareFontShape{JY3}{mc}{m}{it}{<-> ssub* mc/m/sl}{}
46 \end{lstlisting}
47 \newpage
48
49 We also avoid white band problem, by setting both the height and the depth of each 
50 letter/word to 0\,pt. 
51
52 \begin{env}{\relax}
53 #!/bin/sh
54 #長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
55 長い長い長い長い長い長い長い長い長い長い長い長い,長い長い長い長い長い長い
56 #I.長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長いI
57 長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い
58 #IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
59 IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII IIII
60 \end{env}
61
62 Note that any \emph{kinsoku shori} is not performed inside \textsf{lstlisting} environment,
63 as the line~3 in output above. We leave it to further development.
64 \newpage
65
66 \textbf{SOLVED}: LuaTeX-ja specific problem:
67 when the \emph{begin} line of a listings environment ends with JAchar,
68 the first line of the listing is not rendered.
69
70 \begin{env}{problem; shebang not rendered --- 問題}
71 #!/bin/bash
72 :
73 \end{env}
74
75 \begin{LTXexample}[language=TeX]
76 え!1あ,い・あ)う(え
77 え!2あ
78 \end{LTXexample}
79
80 \lstinputlisting{test13-listings.tmp}
81
82 \begin{lstlisting}
83 え!1あアイウエオ
84 え!2あ
85 \end{lstlisting}
86 \end{document}