はじめに
今までWordでレポートを書いていたが,LaTeXで書く方が仕上がりもきれいなので,テンプレートや役に立つコマンドなどをメモしておく.
今回のテンプレートが有用となる対象としては,数式を多く使ったり,図やグラフなどを挿入したりする大学でのレポート用である.
あと,情報系でプログラムコードを書く必要がある人
LaTeXのテンプレート
まず用意するのは適当なファイル(演算子.tex)
ちなみに自分はMacユーザーでLaTeXはAtomを用いてコンパイルしている.
AtomでLaTeXを使う方法は他の人がたくさん記事を書いているので,調べてみて.
test.tex
\documentclass[11pt,a4paper]{jsarticle}
%
\usepackage[dvipdfmx]{graphicx}
\usepackage{amsmath,amssymb}
\usepackage{bm}
\usepackage{ascmac}
\usepackage{enumitem}
\usepackage{subfigmat}
%
\setlength{\textwidth}{\fullwidth}
\setlength{\textheight}{40\baselineskip}
\addtolength{\textheight}{\topskip}
\setlength{\voffset}{-0.2in}
\setlength{\topmargin}{0pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
%
\newcommand{\divergence}{\mathrm{div}\,} %ダイバージェンス
\newcommand{\grad}{\mathrm{grad}\,} %グラディエント
\newcommand{\rot}{\mathrm{rot}\,} %ローテーション
%
%プログラムソースコードを挿入したい人は以下を記入
\usepackage{amsmath,amssymb}% 数式入力に数学必携のパッケージ読み込み
\usepackage{listings,jvlisting}
\lstset{
basicstyle={\ttfamily},
identifierstyle={\small},
commentstyle={\smallitshape},
keywordstyle={\small\bfseries},
ndkeywordstyle={\small},
stringstyle={\small\ttfamily},
frame={tb},
breaklines=true,
columns=[l]{fullflexible},
numbers=left,
xrightmargin=0zw,
xleftmargin=3zw,
numberstyle={\scriptsize},
stepnumber=1,
numbersep=1zw,
lineskip=-0.5ex
}
%プログラムのソースコード関連はここまで
%自分は使わないが,タイトル,著者,日付は以下の3行で挿入できる
%\title{...}
%\author{...}
%\date{\today}
\begin{document}
%ソースコードの名前を自由に変えたいときは以下の1行を追加
%\renewcommand{\lstlistingname}{ソースコード}
%
%
\section{目的}
aaa
\section{課題内容}
aaa
%図の挿入
\begin{figure}[c]
\centering
\includegraphics[width=3.0in]{picture/theory.png}
\caption{グラフ}
\label{fig:formula}
\end{figure}
%横に並べるとき
\begin{figure*}[!t]
\centering
\subcaptionbox{パーのとき \label{fig:pa1}}{\includegraphics[width=2.5in]{picture/re_pa1.png}}
\subcaptionbox{パーでないとき \label{fig:pa0}}{\includegraphics[width=2.5in]{picutre/re_pa0.png}}
\caption{パーのポーズの結果}
\label{fig:re_pa}
\end{figure*}
\section{設計}
\subsection{学習対象}
式番号がつかない式
%
\[
y=2^x
\]
%
式番号がつく式
%
\begin{equation}
y=\frac{cos\sqrt{x_{1}^{2}+x_{2}^{2}}}{2}
\label{eq:formula}
\end{equation}
%
\subsection{aaaaa}
箇条書きができる.中点で表示される.
\begin{itemize}
\item 箇条書き1
\item 箇条書き2
\end{itemize}
箇条書きが(a)(b)(c)になる.
%
\begin{enumerate}[label=(\alph*)]
\item a
\item b
\item c
\end{enumerate}
%
% [label=(\Alph*)]だと(A)(B)(C)
% [label=(\roman*)]だと(i),(ii)
行列書きたいとき
%
\[
w=
\begin{bmatrix}
w_{1,1} & w_{1,2} & ... & w_{1,n} \\
w_{2,1} & w_{2,2} & ... & w_{2,n} \\
w_{3,1} & w_{3,2} & ... & w_{3,n}
\end{bmatrix}
\]
%
\subsection{aaaaa}
%ソースコード追加↓↓↓
\begin{lstlisting}[caption=program.py,label=code]
print("a")
\end{lstlisting}
%ソースコード追加↑↑↑
%表ほしいとき
\begin{table}[hbtp]
\caption{割引率$\gamma$に対する$V(S_{0})$が最大値となるときの$p$とそのときの$V(S_{0})$}
\label{table:gamma}
\centering
\begin{tabular}{ccr}
\hline
$\gamma$ & $p$ & $V(S_{0})$ \\
\hline \hline
0.8 & 0.358633 & 13.17853 \\
0.6 & 0.625682 & 6.67039 \\
0.4 & 1.000000 & 4.74359 \\
0.2 & 1.000000 & 3.79032 \\
0.0 & 1.000000 & 3.00000 \\
\hline
\end{tabular}
\end{table}
\begin{figure}
\begin{subfigmatrix}{2}
\subfigure[$\gamma=0.8$ \label{fig:g_0.8}]{\includegraphics[width=2.5in]{picture/g_0.8.png}}
\subfigure[$\gamma=0.6$ \label{fig:g_0.6}]{\includegraphics[width=2.5in]{picture/g_0.6.png}}
\subfigure[$\gamma=0.4$ \label{fig:g_0.4}]{\includegraphics[width=2.5in]{picture/g_0.4.png}}
\subfigure[$\gamma=0.2$ \label{fig:g_0.2}]{\includegraphics[width=2.5in]{picture/g_0.2.png}}
\end{subfigmatrix}
\caption{各割引率$\gamma$における状態価値の推移}
\end{figure}
\end{document}
あとLaTeXで数式を挿入したいときは以下のページを使うと楽.
今,レポートを作成している最中なので,また何かつまったら追記していく.