tex

texのコマンドとか

レポートのテンプレート
数学レポのテンプレ
物理のかぎしっぽ
TexWiki
よく使う演算記号
岐阜大学
Beamerでスライド
eps画像の挿入
ファイルの置き場所とか
texclip phpでtex画像生成

コンパイル

> platex ***.tex
> (p)xdvi ***.dvi
> xdvipdfmx ***.dvi
YaTeX + emacs の場合
> C-c t j
> C-c t p

スタイルファイルを追加

追加する hoge.sty は 
1. *.tex と同じところに置いておくか,
2. /usr/local/teTex/share/texmf/ptex/platex/base に入れる。
> mktexlsr hoge.sty

インストール

日本語化はいろいろ煩わしいので,teTex を使って入れるのが吉。
デフォルトのインストールフォルダは
/usr/local/teTex/

ギリシャ文字を太字にする

$ \boldsymbol{ \phi } $
 \boldsymbol{ \phi } 

セクションマーク

$ \S 5.1 $
\S 5.1

比例

$ x \propto y $
x \propto y

伸びる矢印

$ f_n \xrightarrow[x \in D]{measure} f $
 f_n \xrightarrow[x \in D]{measure} f 

長い縦棒

$ \frac{df(t)}{dt} \Big| _{t=0} $
 \frac{df(t)}{dt} \Big| _{t=0} 

下括弧・上括弧

$ \overbrace{b^1, \cdots, b^M}^{sequence \beta} $
$ \underbrace{a_1, \cdots, a_N}_{sequence \alpha} $
 \overbrace{b^1, \cdots, b^M}^{sequence \beta} 
 \underbrace{a_1, \cdots, a_N}_{sequence \alpha} 

写像の定義

$ \begin{array}{c c c c c c c}
  k & : & \mathcal{X} \times \mathcal{X} & \to & \mathbb{R}^N \times \mathbb{R}^N & \to & \mathbb{R} \\
    & & \rotatebox[origin=c]{90}{$\in$} & & \rotatebox[origin=c]{90}{$\in$} & & \rotatebox[origin=c]{90}{$\in$} \\
    & & (\xx,\xx') & \mapsto & (\mathbf{\phi(x)}, \mathbf{\phi(x')}) & \mapsto & \sum_{i=1}^N \phi_i(\xx) \phi_i(\xx')
\end{array} $
参照:kernel.jpg

可換図式

\usepackage{ amscd }

$ \begin{CD}
  X = \varprojlim_{n\to\infty} A_n @> > > \mathrm{Gal} (L_\infty / K_\infty) \\
      @V V V @V V V \\
      A_{n+1} @> {\left(\frac{L_{n+1}/K_{n+1}}{\cdot}\right)} >> \mathrm{Gal} (L_{n+1}/K_{n+1}) \\ 
      @V{N_{K_{n+1}/K_n}} V V @V V{\text{res}} V \\
      A_n @> {\left(\frac{L_n/K_n}{\cdot}\right)} > > \mathrm{Gal} (L_n/K_n)
\end{CD} $
参照:CD.png

場合分け

$ g(x) =
 \begin{cases}
   0 & \mbox{if } x \in [0,1) \\
   1 & \mbox{if } x = 2
 \end{cases} $

g(x) = 
 \begin{cases}
   0 & \mbox{if } x \in [0,1) \\
   1 & \mbox{if } x=1 \end{cases}


\itembox環境で数式1本を囲む

\begin{itembox}[l]{Sigmoidal kernel}
  \vspace{-\baselineskip} % 数式だけのitemboxは一行下がってしまうので上げる
  \begin{equation}
    k(\xx,\xx') := \tanh(a \xx^\mathrm{T} \xx' + b)
  \end{equation}
\end{itembox}
数式1本だと改行が入ってしまうので,\vspaceで持ち上げる。

\itemize環境での記号について

\noindent \underline{the perceptron algorithm}
\begin{itemize}
  \item[{\rm :-)}] hoge 
  \item[:-(] hage
  \item[$\circ$] hoge
  \item[$\times$] hage
  \item[$\nearrow$] guaranteed to find a solution in a finite number of steps.
  \item[$\searrow$] hage
\end{itemize}

同値変形・推論をきれいにつなぐ

一本目の式にはなにもなくて,二本目以降は ⇔ とか ⇒ で揃えたいとき。 
\begin{eqnarray}
&& \hspace{-3.5zw} Ax = b \\
&\Leftrightarrow& (QR)x = b \\
&\Leftrightarrow& Rx = Q^\mathrm{T}b \\
\end{eqnarray}

行列

\begin{pmatrix}
  a_{11} & \cdots & a_{1N} \\
  \vdots & \ddots & \vdots \\
  a_{N1} & \cdots & a_{NN}
\end{pmatrix}
p () b [] B {} v,V ||

\begin{bmatrix}
  a_{11} & \cdots & a_{1N} \\
  \vdots & \ddots & \vdots \\
  a_{N1} & \cdots & a_{NN}
\end{bmatrix}

線を引いたりするには array 環境でないとだめみたい。
\left[
 \begin{array}{cc:cc}
  1 & 2 & 3 & 4 \\
  \hdashline
  2 & 4 & 6 & 8 \\
  \cdashline{2-3}
  10 & 12 & 14 & 16
 \end{array}
\right]



定理環境を作る

普通に使うとき。
\usepackage{amsthm}
\newtheorem{thm}{Th.}[section] % 節で区切る。
\newtheorem{cor}[thm]{Cor.} % 定理と同じ番号を使う。
・・・
\begin{thm}[おどろきの定理]
  ここに定理を書く。
\end{thm}
いろいろカスタマイズしたいときは,theorem の方をロードする。
関数解析のレポートで使った例
\usepackage{theorem}
...
\theoremstyle{break}          % 定理名を表示した後に改行
\newtheorem{thm}{定理}[section]
\newtheorem{cor}[thm]{系}
\newtheorem{ex}[thm]{例}
\newtheorem{prop}[thm]{命題}
\newtheorem{dfn}[thm]{定義}
\newtheorem{q}{問}[section]

n乗根

\sqrt[n]{a}
\sqrt[n]{a}

新しい関数記号を定義する

\usepackage{amsmath,amssymb}
\DeclareMathOperator*{\argmax}{\textrm{arg max}} % プリアンブルに書くこと。
アスタリスクを付けると,上付き・下付きが \sum とかと同じように真上・真下に着く。

番号の調整

\setcounter{section}{6}
\setcounter{equation}{3}
→ 式番号は (6.3) になる!

重積分と累次積分

\int_{-\infty}^\infty \! \cdots \! \int_{-\infty}^\infty f(x_1, \cdots, x_n) dx_1 \cdots d_xn
 \int_{-\infty}^\infty \! \cdots \! \int_{-\infty}^\infty f(x_1, \cdots, x_n) dx_1 \cdots dx_n
</pre>
<p>


近似には2種類ある

\approx   \approx
\sim      \sim      ←こっちのが粗い近似として使い分けられる。

参考文献

\cite[(省略可)]{mrt96} 
...
\renewcommand{\bibname}{参考文献} % (jreportの場合)デフォルトで「関連図書」となるのを変更
\begin{thebibliography}{1}
\bibitem[Murata, 1996]{mrt96}
  Murata,N. (1996)
  An Integral Representation of Functions Using Three-layered Networks and Their Approximation Bounds.
  Neural Networks, Vol.9, No.6, pp.947-956
\end{thebibliography}

jreportでマージンの調整

\setlength{\textwidth}{\fullwidth}が使えない!
\setlength{\textwidth}{0.75\paperwidth}
\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in}
\setlength{\textheight}{45\baselineskip}
\addtolength{\textheight}{\topskip}
\setlength{\voffset}{-0.2in}
\setlength{\topmargin}{0pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}

Appendix

\appendix     % これ以降は章立てが A,B,...に変わる。
\renewcommand{\appedixname}{Appendix }     % デフォルトの「付録 A」から「Appendix A」に変更

図と表

基本的な図
\usepackage[dvips]{graphicx}
...
\begin{figure}[htbp]
 \begin{center}
  \includegraphics[width=100mm]{fig1.eps}
 \end{center}
 \caption{タイトル}
 \label{fig:hoge}
\end{figure}
複数並べる
\begin{figure}[htbp]
 \begin{minipage}{0.5\hsize}
  \begin{center}
   \includegraphics[width=70mm]{fig1.eps}
  \end{center}
  \caption{タイトル1}
  \label{fig:hoge}
 \end{minipage}
 \begin{minipage}{0.5\hsize}
  \begin{center}
   \includegraphics[width=70mm]{fig2.eps}
  \end{center}
  \caption{タイトル2}
  \label{fig:hage}
 \end{minipage}
\end{figure}
 table の中に tabular を作る。表を描くのは tabular
\begin{table}[h]
\caption{表のタイトル}\label{tbl:test} % 上部に付ける場合
\begin{center}
\begin{tabular}{|c|c|} \hline
  何某 & 何某 \\ \hline\hline
  何某 & 何某 \\ \hline
\end{tabular}
\end{center}
\end{table}
文章を回しこむ \section とか itemize が後に続くとダメ。\caption も上手く動かないので自分で工夫する。
\usepackage{wrapfig}
...
\addtocounter{figure}{1} ←工夫その1
\begin{wrapfigure}{r}{50mm}
\label{fig:model}
\begin{center}
  \includegraphics[width=50mm]{graphical_model2.eps}
  \hspace{5mm}図\arabic{figure} 説明文 ←工夫その2
\end{center}
\end{wrapfigure}

余白の調節とか

以下は @ を使うので,makeatletter makeatother で挟む。
sectionの調節
\renewcommand\section{\@startsection {section}{1}%
{\z@}%
{-1ex \@plus -1ex \@minus -.2ex}% ←sectionの上の行間
{1ex \@plus.2ex}%                 ←sectionの下の行間
{\normalfont\large\bfseries}}     ←sectionの書式
subsectionも同じ
\renewcommand\subsection{\@startsection {subsection}{1}%
{\z@}%
{-1ex \@plus -1ex \@minus -.2ex}%
{1ex \@plus.2ex}%
{\normalfont\large\bfseries}}
タイトルページに機関名とか入れたい。
\def\firstpage{[機関名]\hfill[雑誌名]}
\def\ps@titlepage{%
  \@oddhead{\hfil\firstpage\hfil}%
  \let\@evenhead\@oddhead
  \def\@oddfoot{\hfil}%
  \let\@evenfoot\@oddfoot
  \let\@mkboth\@gobbletwo
}
...
\begin{document}
\maketitle
\thispagestyle{titlepage}     ← \maketitleはpagestyle{plain}をやってくれるので,その後に置いて上書きする。

長い数式を折り返す

\begin{eqnarray}
P(X_{1:4} | Y_{1:4}) &=& \prod_{t=1}^4 P(X_t | X_{1:t-1}, Y_{1:t}) \\
&=& \prod_{t=1}^4 \int P(X_t, T_{t:t-1} | X_{1:t-1}, Y_{1:t}) dT_{t} dT_{t-1}
\\ 
&=&
\begin{split}
\prod_{t=1}^4 \int 
P(X_t | T_{t:t-1}, X_{1:t-1}, Y_{1:t}) 
P(T_t | T_{t-1}, X_{1:t-1}, Y_{1:t}) \\
P(T_{t-1} | X_{1:t-1}, Y_{1:t}) 
dT_{t} dT_{t-1}
\end{split}
\\
&=&
\prod_{t=1}^4 \int 
P(X_t | T_t) 
P(T_t | T_{t-1}, Y_{t}) 
P(T_{t-1} | X_{t-1}, Y_{t-1}) 
dT_{t} dT_{t-1}
\\
&=& \prod_{t=1}^4 P(X_t | Y_t)
\end{eqnarray}

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2010年12月16日 18:33
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。
添付ファイル