LoginSignup
3
4

More than 3 years have passed since last update.

LaTeX レポート作成のおすすめパッケージ

Posted at

この記事は ISer Advent Calendar 2020 の 18 日目として書かれました.
なお今日はクリスマス・イブです.あれ?

ここでは,LaTeX でレポートを作成する際に自分がよく使うものをまとめてみました.
皆さんのレポート作成の手助けとなれば幸いです.

bm パッケージ

ベクトルを太字+斜体で書きたいときなどに使えるパッケージです.
文字列を \bm{} で囲むと太字+斜体に変換してくれます.

\[
    A\bm{x} = \bm{b}
\]
A\boldsymbol{x}= \boldsymbol{b}

physics パッケージ

行列や微分をはじめとする数式を簡単に書けるパッケージです.
このドキュメントにすべての機能が載っていますが,少しだけ紹介します.
https://www.ctan.org/pkg/physics

行列

わざわざ \begin{matrix} などと入力しなくても行列を書くことができます.

\[
    \mqty( 1 & 2 \\ 3 & 4 )
\]
\begin{pmatrix}
    1 & 2 \\
    3 & 4
\end{pmatrix}

微分

${\mathrm{d}y}/{\mathrm{d}x}$ の形の微分形を簡単に書くことができます.

\[
    \dv[2]{y}{x} + p\dv{y}{x} + qy = f(x)
\]
\frac{\mathrm{d}^2y}{\mathrm{d}x^2} + p\frac{\mathrm{d}y}{\mathrm{d}x} + qy = f(x)

listings パッケージ

ソースコードを挿入するときに使えるパッケージです.
オプションでフォントを変更したり,行番号を挿入できたりします.

\lstinputlisting[
    basicstyle=\ttfamily\footnotesize,
    frame=single,
    numbers=left
]{code.py}
code.py
def fact(n):
    if n <= 1: 
        return 1
    else:
        return n * fact(n - 1)

img02.png
中身に日本語が含まれる場合,追加で jlisting パッケージをインクルードする必要があります.

bussproofs パッケージ

論理式の証明図を書きたい(描きたい)ときに使えます.
ドキュメントはこちら
https://www.ctan.org/pkg/bussproofs

\begin{prooftree}
        \AxiomC{$(A\land C)\lor (B\land C)$}
                    \AxiomC{$[A\land C]_1$}
                \UnaryInfC{$A$}
            \UnaryInfC{$A\lor B$}
                \AxiomC{$[A\land C]_1$}
            \UnaryInfC{$C$}
        \BinaryInfC{$(A\lor B)\land C$}
                    \AxiomC{$[B\land C]_1$}
                \UnaryInfC{$B$}
            \UnaryInfC{$A\lor B$}
                \AxiomC{$[B\land C]_1$}
            \UnaryInfC{$C$}
        \BinaryInfC{$(A\lor B)\land C$}
        \RightLabel{\small 1}
    \TrinaryInfC{$(A\lor B)\land C$}
\end{prooftree}

img01.png

ユーザスニペット

LaTeX 限定の機能ではないですが,とても使い勝手がいいので書きます.

左下の歯車マークから "User Snippets" を選択し,latex.json を選択すると登録できます.

たとえば,latex.json に次のように書いておくと,tex ファイル上で code と入力するだけでここで登録したスニペットが挿入されます.

{
    "code": {
        "prefix": "code",
        "body": [
            "\\lstinputlisting[",
            "\tbasicstyle=\\ttfamily\\footnotesize,",
            "\tframe=single,",
            "\tnumbers=left",
            "]{}"
        ],
        "description": "ソースコード用テンプレート"
    }
}
\lstinputlisting[
    basicstyle=\ttfamily\footnotesize,
    frame=single,
    numbers=left
]{}

おわりに

他にもまだまだありそうな気がしますが,とりあえずここまでで.
目を通してくださってありがとうございました.

3
4
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
3
4