LoginSignup
1
0

More than 5 years have passed since last update.

jlising 使い方

Posted at

jlistingを使うための準備

1.jlisiting.styファイルをダウンロードしてくる.
2.ダウンロードしたstyファイルをtexファイルと同じディレクトリに置く.

3.texファイルに以下を追加

*.tex
\usepackage{listings,jlisting} % ソースコード埋め込み
% jlisting
\renewcommand{\lstlistingname}{リスト}
\lstset{language=c,
  basicstyle=\ttfamily\scriptsize,
  commentstyle=\textit,
  classoffset=1,
  keywordstyle=\bfseries,
  frame=tRBl,
  framesep=5pt,
  showstringspaces=false,
  numbers=left,
  stepnumber=1,
  numberstyle=\tiny,
  tabsize=2
}

language等の設定は,適宜変更する.

使い方

以下のように記述する.

*.tex
\begin{figure}[t]
    \begin{lstlisting}[caption=ハローワ―るど,label=ハロー]
    #include <stdio.h>
    int main(){
        printf("hello world\n");
    }
    \end{lstlisting}
\end{figure}

2段組ではなく1段組にしたいときは
以下のように記述する

*.tex
\begin{figure*}[t]
    \begin{lstlisting}[caption=ハローワ―るど,label=ハロー]
    #include <stdio.h>
    int main(){
        printf("hello world\n");
    }
    \end{lstlisting}
\end{figure*}

リストを参照したいときは,
リスト\ref{ハロー}とする.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0