0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

論文 Latex チートシート

Last updated at Posted at 2025-01-28

論文 Latex チートシート

はじめに

論文でLatexを使って書いているけど,書き方が分からない..どうしよう..という時に見てください.

章立て

    • 章は\chapter{}で書けます.
    \chapter{はじめに}
    
    image.png

    • 節は\section{}で書けます.
    \chapter{はじめに}
    \section{ほげ}
    
    image.png

    • 項は\subsection{}で書けます.
    \chapter{はじめに}
    \section{ほげ}
    \subsection{hoge}
    
    image.png

    • 目は\subsubsection{}で書けます.
    \chapter{はじめに}
    \section{ほげ}
    \subsection{hoge}
    \subsubsection{aaaaaaa}
    
    image.png

図表

  • 図表で共通の書き方

    • 図表の配置

    t: ページの一番上
    b: ページの一番下
    h: ソース中で現れた位置に表示する
    p: 図や表のみから成るページを作成して,そこに表示する.
    ※基本はtbpで書く.

    • 図表のタイトル

    図表のタイトルは\caption{}で書きます.


  • 図の書き方

    • パッケージ

    \usepackage[dvipdfmx]{graphicx}
    
    • 図の参照

    図を参照するには,\ref{}を用います.
    \begin{figure}\label{}でラベル付けした名前(以下の例で言うと「graph」)を記述すれば自動的に図番号が割り当てられる.
    そのため,新しい図を挿入した際に,わざわざ図番号を変える必要がない.

    • 図を置いているファイルの参照

    オススメはtexファイルのディレクトリ内に画像を置いておくディレクトリを作成すること.
    私は,figsの中に画像を入れています.
    画像はpdfやpng,jpegでも大丈夫です.

    以下に,図\ref{graph}を示す.
    
    \begin{figure}[tbp]
      \centering
      \includegraphics[width=1.0\linewidth]{./figs/graph.pdf}
      \caption{図の書き方}
      \label{graph}
     \end{figure}
    

    本文
    image.png


    image.png


  • 表の書き方

    • 図の参照

    表を参照するには,\ref{}を用います.
    \begin{table}\label{}でラベル付けした名前(以下の例で言うと「alpha_count」)を記述すれば自動的に図番号が割り当てられる.
    そのため,新しい表を挿入した際に,わざわざ表番号を変える必要がない.

    • 配置

    l:左寄せ
    c:中央寄せ
    r:右寄せ

    • 2行目以降のカラムの配置

    \begin{tabular}[|配置|配置|]のように書く.
    配置|は表の縦の枠線を表す.
    配置の数は表中の列数分にする.以下の例の場合は2列なので{|c|c|}としている.

    • 1行目のカラムの配置

    \multicolum{連結セル数}{|配置|}{列の名前}を使って書く.
    基本的には\multicolum{1}{|配置|}{列の名前}で書く

    • 表中の値の書き方

    同じ行のことなる列どおしを&で繋ぐ
    \hlineは表中の横の枠線を表す.

    以下に,図\ref{alpha_count}を示す.
    \begin{table}[tbp]
      \centering
      \caption{表の書き方}
      \label{alpha_count}
      \begin{tabular}{|c|c|}  \hline
        \multicolumn{1}{|c|}{alphabet} & \multicolumn{1}{|c|}{count} \\ \hline \hline
       A & 1 \\ \hline
       B & 2 \\ \hline
       C & 3 \\ \hline
       D & 4 \\ \hline
       E & 5 \\ \hline
      \end{tabular}
     \end{table}
    

    本文
    image.png

    image.png

参考文献

参考文献の書き方は2パターンあります.

1.texファイルに直接書く
2.bibtexに書く

おすすめは2番です.
理由としては,使いまわしができることや参考文献の書き方(体裁)が整っていることがあります.

  • パッケージ

    \usepackage{url}
    \usepackage{cite}
    

  • setting.json

    pbibtexのコメントアウトを外す.

  • 直接書く方法

    参考文献参照です\cite{genkou1}
    \begin{thebibliography}{99}
    \bibitem{th} thayato,THayatoの自己紹介,2025年1月, \url{https://thayato0418.github.io/},accessed:2025/1/28
    \end{thebibliography}
    

    本文
    image.png
    参考文献
    image.png

    • 本文の最後に書く

    \begin{thebibliography}{num}numには参考文献の桁数分だけ9を記述する.
    つまり,1桁であれば9,2桁であれば99と記述する.
    多めに99と書くのが無難だと思います.

    • 参考文献をリスト化する

    \bibitem{参照ラベル}と書く.
    参照ラベルは任意の文字.

    • 参照

    \bibitem{参照ラベル}で書いた参考文献を参照したい際は,\cite{参照ラベル}と書く.


  • bibtexに書く方法

    Tex

    参考文献参照です\cite{th}

    bunken.bib

    @webpage{th,
    title        = {THayatoの自己紹介},
    author       = {thayato},
    organization = {},
    url          = {\url{https://thayato0418.github.io/}},
    refdate      = {2025-01-28}
    }
    

    本文
    image.png
    参考文献
    image.png

    上記では,webpageの参照のみ取り上げたが他にも論文や書籍なども可能です.
    詳しくは,cs2srt.bst(自研究室のbstファイル)を見てください.

索引

:warning:注意点
エディタの文字コードはUTF-8を想定しています.
Shift-JISで書くと違った挙動になる可能性があります.

  • パッケージ

    \usepackage{makeidx}
    

  • setting.js

    makeindexのコメントアウトを外す.

  • \printindex

    Texファイルで索引リストを挿入したい場所に\printindexを書く.

  • \index{索引での表示名}の書き方

    • 英語,ひらがな,カタカナは表示名にそのまま書いてよい.
    • 漢字の場合,もしくは漢字を含む場合は\index{読み@索引での表示名}と書く.

Tex

English\index{English}
ひらがな\index{ひらがな}
カタカナ\index{カタカナ}
ひらがな漢字\index{ひらがなかんじ@かたかな漢字}
カタカナ漢字\index{かたかなかんじ@かたかな漢字}
English漢字\index{Englishかんじ@English漢字}
漢字\index{かんじ@漢字}

本文
image.png


その他

  • screen

    logやコード,プロンプトの結果などを挿入したい場合に使う

    \usepackage{ascmac}
    
    pingの結果を示す\ref{ping}\begin{figure}[tbp]
    \centering
    \begin{screen}
    \$ ping 8.8.8.8
    
    8.8.8.8 に ping を送信しています 32 バイトのデータ:\\
    8.8.8.8 からの応答: バイト数 =32 時間 =1ms TTL=62\\
    8.8.8.8 からの応答: バイト数 =32 時間 \textless1ms TTL=62\\
    8.8.8.8 からの応答: バイト数 =32 時間 \textless1ms TTL=62\\
    8.8.8.8 からの応答: バイト数 =32 時間 =1ms TTL=62\\
    
    8.8.8.8 の ping 統計:\\
      パケット数: 送信 = 4、受信 = 4、損失 = 0 (0% の損失)、\\
    ラウンド トリップの概算時間 (ミリ秒):\\
      最小 = 0ms、最大 = 1ms、平均 = 0ms
    \end{screen}
    \caption{8.8.8.8に対するpingコマンドの応答}
    \label{ping}
    \end{figure}
    

    image.png


  • 丸の中に数字を書く

    \newcommand{\ctext}[1]{\raise0.2ex\hbox{\textcircled{\scriptsize{#1}}}} % プリアンプルで定義する
    \ctext{1} % 本文:➀
    

  • 別のlatexを挿入する

    \input{input.tex}
    
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?