TeXメモ

自分用のメモです。

図、表などの番号に章番号をつける

\renewcommand{\theequation}{\thesection.\arabic{equation}}
\renewcommand{\thefigure}{\thesection.\arabic{figure}}
\renewcommand{\thetable}{\thesection.\arabic{table}}
\makeatletter
  \@addtoreset{equation}{section}
  \@addtoreset{figure}{section}
  \@addtoreset{table}{section}
\makeatother

JPEG、PNG等の画像を含んだPDFを出力できるようにする

\usepackage[dvipdfm]{graphicx}

画像ファイルを探しに行くパスを追加する

\graphicspath{{../hoge/fuga/}}

画像の参照など

\newcommand{\figref}[1]{\figurename \ref{fig:#1}}
\newcommand{\tblref}[1]{\tablename \ref{tbl:#1}}
\newcommand{\eqnref}[1]{\eqref{eqn:#1}}

ToDo: 多引数にも対応させたい。(例: \figref{a}{b}{c} => 図1.2, 1.3, 1.4)不可能?

wrapfig、subfigureの使い方

\usepackage{wrapfig}
\usepackage[tight, scriptsize]{subfigure}

\begin{wrapfigure}{r}{0.4\hsize}
\begin{center}
    \includegraphics[width=1\hsize]{hage.eps}
    \caption{caption}
    \label{hage}
\end{center}
\end{wrapfigure}


\begin{figure}[htbp]
\begin{center}
  \subfigure[subcaption1]{
    \includegraphics[width=0.4\hsize]{hoge.eps}
    \label{hoge}
  }
  \subfigure[subcaption2]{
    \includegraphics[width=0.4\hsize]{fuga.eps}
    \label{fuga}
  }
  \caption{caption}
  \label{label}
\end{center}
\end{figure}

レポート課題用

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{(\arabic{subsection})}

\section{hogehoge} % 問1 hogehoge
\subsection{} % (1)

プログラムのコードを書く環境

\newenvironment{code} {
    \begin{quote}
    \ttfamily\footnotesize
    \baselineskip=9pt
    \newcommand{\q}{\hspace*{2em}}
}{
    \end{quote}
}

場合分け

\begin{align}
|a| &= 
\begin{cases}
  a  & \text{$a \leq 0$のとき}\\
  -a & \text{$a < 0$のとき}
\end{cases}
\end{align}

注釈付きの数式

\begin{alignat}{2}
\omega  &= V_i * 650 & \qquad &\text{想定していた挙動。}\\
\omega' &= (V_i - 0.11) * 550 
                     &        &\text{実際の挙動}
\end{alignat}