LaTeX
エラーメッセージ集
テンプレート集
http://www.latextemplates.com/
体裁設定
\documentclass[a4j,twocolumn]{jarticle}
\setlength{\textwidth }{ 54zw}
\setlength{\textheight}{ 88zh}
\setlength{\topmargin }{-40mm}
\setlength{\oddsidemargin }{-12mm}
\setlength{\evensidemargin}{-10mm}
\usepackage[dvips]{graphicx} % 画像用
\usepackage[margin=4cm]{geometry} % 上下左右の余白を4cm空ける
\pagestyle{empty}
\usepackage{fancyhdr} % ヘッダーフッターをつけるパッケージ
\pagestyle{fancy}
\lhead{合同ゼミ} % ヘッダーの左側
\chead{} % ヘッダーのまんなか
\rhead{2011年05月11日火曜日} % ヘッダーの右側
\renewcommand{\headrulewidth}{0pt} % ヘッダーのラインを書かない
ヘッダーとフッターの他の書き方
\usepackage{fancyhdr} % ヘッダーフッターをつけるパッケージ
\pagestyle{fancy} % 同上
\lhead{\leftmark} % ヘッダーの左側 (章を表示)
\chead{} % ヘッダーの中央
\rhead{} % ヘッダーの右側 (節を表示)
\lfoot{Title} % フッターの左側 (タイトル)
\cfoot{\thepage} % フッターの中央 (ページ番号)
\rfoot{2011年09月26日月曜日} % フッターの右側 (日付)
\renewcommand{\headrulewidth}{2pt} % ヘッダーの線
\renewcommand{\footrulewidth}{2pt} % フッターの線
http://www.biwako.shiga-u.ac.jp/sensei/kumazawa/tex/fancyhdrreport.html
キャプションの変更
直接編集する場合
\makeatletter
\long\def\@makecaption#1#2{\footnotesize%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1: #2}
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}
\fi
\vskip\belowcaptionskip}
\makeatother
パッケージを使用して変更する場合
caption パッケージを使用する
\usepackage[hang,bf]{caption}
http://abigfishinalittlepond.blogspot.jp/2010/09/latexcaption.html
http://sow-te.hatenablog.com/entry/2015/01/07/211646
数式番号の変更
\makeatletter
\renewcommand{\theequation}{%
\thesection.\arabic{equation}}
\@addtoreset{equation}{section}
\makeatother
図番号の変更
\makeatletter
\renewcommand{\thefigure}{%
\thesection.\arabic{figure}}
\@addtoreset{figure}{section}
\makeatother
表番号の変更
\makeatletter
\renewcommand{\thetable}{%
\thesection.\arabic{table}}
\@addtoreset{table}{section}
\makeatother
しおりの文字化け対策 (for SJIS)
\usepackage{atbegshi}
\AtBeginShipoutFirst{\special{pdf:tounicode 90ms-RKSJ-UCS2}}
\ifnum 42146=\euc"A4A2
\AtBeginDvi{\special{pdf:tounicode EUC-UCS2}}
\else
\AtBeginDvi{\special{pdf:tounicode 90ms-RKSJ-UCS2}}
\fi
http://oku.edu.mie-u.ac.jp/~okumura/texwiki/?hyperref
http://www.biwako.shiga-u.ac.jp/sensei/kumazawa/tex/hyperref.html
日本語文章作成時の Font 警告対策
dvipdfmx を実行した時に、以下のようなエラーが出る。
LaTeX Font Warning: Font shape `JT1/mc/m/it' undefined
(Font) using `JT1/mc/m/n' instead on input line 161.
その場合、以下のファイルをダウンロードし
dummy.tex
\input{dummy}
を付け加える。
Ubuntu 上で dvipdfmx 実行時のフォント埋め込み
http://nanase.hatenablog.jp/entry/2013/08/09/023416
相互参照
図: \label{fig:namefig} -> \ref{fig:namefig}
表: \label{tb:nametb} -> \ref{tb:nametb} ! "table" ではない←よくまちがえてしまう
式: \label{eq:nameeq} -> \ref{eq:nameeq}
http://www002.upp.so-net.ne.jp/latex/sansho.html
参考文献の表示別参照法
\citet{namebib} -> Name et al. (1989)
\citep{namebib} -> (Name et al., 1989)
\citealt{namebib} -> Name et al. 1989
\citealp{namebib} -> Name et al., 1989
http://keizai.okomeda.net/latex/bib/bib04.html
*** ここから再編集 (2016-06-25) ***
section の改変
\makeatletter
\renewcommand{\section}{%
\@startsection{section}%
{1}%
\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{0.2ex \@plus.2ex}%
{\normalfont\normalsize\bfseries}%
}%
\makeatother
▲ ▼
subsection の改変
\makeatletter
\renewcommand{\subsection}{%
\@startsection{subsection}%
{1}%
{\z@}%
{-0.0ex \@plus -1ex \@minus -.2ex}%
{0.1ex \@plus.2ex}%
{\normalfont\normalsize\bfseries}%
}%
\makeatother
▲ ▼
section,subsection の表示変更
\renewcommand{\thesection}{ \arabic{section}.}
\renewcommand{\thesubsection}{ \arabic{section}.\arabic{subsection}}
1. はじめに
1.1 これまでの解析 のように出力される。
http://osksn2.hep.sci.osaka-u.ac.jp/~naga/miscellaneous/tex/tex-tips1.html
▲ ▼
部分的に行間を変える
\newenvironment{minilinespace}{
\baselineskip = 1mm
}
\begin{minilinespace}
[行間を変えたい内容]
\end{minilinespace}
▲ ▼
表紙
\title{NUMAアーキテクチャについて}
\author{\normalsize *AMD太郎(PC大学大学院CPU研究科CPUアーキテクチャ専攻)}
\date{}
\maketitle
\thispagestyle{empty} % 要旨などで、はじめのページ番号を出させない.
▲ ▼
表紙 (\maketitleを使わない方法)
\begin{titlepage}
\begin{center}
\vspace{5cm}
{\large 第1回}\\
\vspace{5cm}
{\LARGE NUMAアーキテクチャ講習会}\\
\vspace{10cm}
{\large CPU大学 博士課程 1年}\\
\vspace{0.2cm}
{\large AMD 次郎}\\
\vspace{0.2cm}
{\large 平成23年09月26日}\\
\vspace{6cm}
\end{center}
\end{titlepage}
▲ ▼
図 (png)
\begin{figure}
\centering
\includegraphics[bb=0 0 800 600,width=7.0cm]{fig.1.png}
\caption{hoge}
\end{figure}
▲ ▼
図 (eps)
\begin{figure}
\centering
\includegraphics[width=7.0cm]{fig.1.eps}
\caption{hoge}
\end{figure}
▲ ▼
図 (pdf)
\begin{figure}
\centering
\includegraphics[width=7.0cm]{fig.1.pdf}
\caption{hoge}
\end{figure}
▲ ▼
boundingbox
コンパイルする前に
$ ebb fig.1.pdf
として、"fig.1.ebb" というファイルを得る。 このファイルを、fig.1.pdf と同じディレクトリにおいた状態でTexをコンパイルする
▲ ▼
表
\begin{table}
\begin{center}
\small 表
\end{center}
\begin{center}
\scriptsize
\begin{tabular}{|c||c|c|c|c||c|} \hline
&高知市 &足摺岬 &日和佐 &魚梁瀬 &. \\
月 &付近 &付近 &付近 &付近 &合計 \\ \hline\hline
1 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
2 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
3 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
4 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
5 &$1\,$ &$0\,$ &$0\,$ &$0\,$ &$1\,$ \\ \hline
6 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
7 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
8 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
9 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
10 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
11 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline
12 &$0\,$ &$0\,$ &$0\,$ &$0\,$ &$0\,$ \\ \hline\hline
合計 &$1\,$ &$0\,$ &$0\,$ &$0\,$ &$1\,$ \\ \hline
\end{tabular}
\end{center}
\end{table}
▲ ▼
表のセルを結合する(列を結合する場合)
プレアンブルで
\usepakage{multirow}
を宣言し
\begin{table}
\centering
\tiny
第1表 \\
\begin{tabular}{c|c|c|c|c} \hline
\multirow{2}{*}{結合する行1} &結合しない行1 &結合しない行2 &\multirow{2}{*}{結合する行2} &\multirow{2}{*}{結合する行3} \\
&単位 &単位 & & \\ \hline ←結合する行では空白にする
豚骨ラーメン &いっぱい &たべたい &よー &よー \\ \hline
\end{tabular}
\end{table}
▲ ▼
表の幅を変更する
{\tabcolsep = 5mm
・・・
}
と言う風にtabular環境を囲む。
http://ideas.paunix.org/latex/latex_6_tabular.htm
▲ ▼
図・表を最後に全部並べる
\usepackage{endfloat}
endfloat.sty を使用する
http://www.biwako.shiga-u.ac.jp/sensei/kumazawa/tex/endfloat.html
▲ ▼
詰めて表示する
デフォルトだと、1ページに1つしか表示してくれないので、 詰めてあげるときは、 http://www.biwako.shiga-u.ac.jp/sensei/kumazawa/tex/endfloat.html に書いてあるようにプレアンブルに、
\renewcommand{\efloatseparator}{\medskip}
を追記しておく。
http://www.proton.jp/main/latex/sty.html#endfloat
http://www.biwako.shiga-u.ac.jp/sensei/kumazawa/tex/endfloat.html
▲ ▼
図・表のキャプションをカスタマイズ
http://osksn2.hep.sci.osaka-u.ac.jp/~naga/miscellaneous/tex/tex-tips2.html#Anchor-2.7.-4248
▲ ▼
図・表の強制配置
\begin{figure}[!ht] \begin{table}[!ht]
▲ ▼
謝辞
\section*{\centering{謝辞}}
ここに謝意を表します.
▲ ▼
参考文献
\begin{center}
\scriptsize
\begin{thebibliography}{99}
\bibitem{1} 木島丈一郎, 2010: AMDCPUとIntelCPUのアーキテクチャの比較について.
\end{thebibliography}
\end{center}
▲ ▼
参考文献の引用 (natbib.sty 形式)
\citet{引用キー} -- Dasgupta et. al. (1979)
\citep{引用キー} -- (Dasgupta et. al. ,1979)
\citep*{引用キー} -- (Dasgupta, Hammond and Maskin, 1990)
\citealt{引用キー} -- Dasgputa et. al. 1979
\citealt*{引用キー} -- Dasupta, Hammond and Maskin 1979
\citealp{引用キー} -- Dasgputa et. al., 1979
\citealp*{引用キー} -- Dasupta, Hammond and Maskin, 1979
\citeauthor{引用キー} -- 著者名の短縮形を表示
\citeauthor*{引用キー} -- 著者名を表示
\citeyear{引用キー} -- 年号のみ表示
\citeyearpar{引用キー} -- (年号) を表示
\citetext{コメント} -- (コメント) を表示
http://keizai.okomeda.net/latex/bib/bib04.html
http://keizai.xrea.jp/latex/bib/bib04.html
▲ ▼
微妙な隙間を詰めるor広げる
\vspase{20mm} % 広げる
\vspase{-20mm} % 詰める
▲ ▼
配置
\centering % 中央配置
\raggedright % 左寄せ
\raggedleft % 右寄せ
▲ ▼
ほかの寄せ方
http://trialpc.net/triple/2008/02/tex-3.php
▲ ▼
太文字
\{bf 太文字になる}
▲ ▼
ドイツ語等のウムラウト
\"{o}
http://mikilab.doshisha.ac.jp/dia/seminar/latex/doc/uml.html
▲ ▼
アンダーラインを引く
\underline{文字}
▲ ▼
複数行に渡ってアンダーラインを引く場合
http://d.hatena.ne.jp/takehikom/20081108/1226091905
を参考にして、「jumoline.sty」というパッケージを以下のURLからダウンロードする。
http://www.htc.nagoya-u.ac.jp/~yamamoto/lecture/tex/stylemacro/jumoline.sty その後、ダウンロードしたファイルを、しかるべき場所へ置き、 プリアンブルに以下のように書く。
\usepackage{jumoline}
文章中で使用するときは、
\Underline{文字}
とする。
▲ ▼
フォントの追加
/usr/share/texlive/texmf-dist/fonts/
以下の適当な場所に font ファイルを置く
その後,以下のコマンドを打って dvipdfmx で読み込めるようにする
sudo mktexlsr
sudo texhash
▲ ▼
フォントの変更
Italic
{\textit Italic}
{\it Italic}
Sans Selif
{\textsf Sans Selif}
Typewriter
{\texttt Typewriter}
http://www.rsch.tuis.ac.jp/~mizutani/online/latex/font.html
http://ja.wikibooks.org/wiki/TeX/LaTeX%E5%85%A5%E9%96%80#.E6.9B.B8.E4.BD.93
▲ ▼
Arialのフォントを使用する
プリアンブルに以下を記述するだけでOK。
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
http://tex.stackexchange.com/questions/23957/how-to-set-font-to-arial-throughout-the-entire-document
▲ ▼
フォントの色の変更
\textcolor{red}{この文字だけ赤色になる}
http://www.geocities.jp/kujira_pumpkins/text/color/color.html
▲ ▼
文字サイズ
{\tiny 大きさ}
{\scriptsize 大きさ }
{\footnotesize 大きさ}
{\small 大きさ}
{\normalsize 大きさ}
{\large 大きさ}
{\Large 大きさ}
{\LARGE 大きさ}
{\huge 大きさ}
{\Huge 大きさ}
▲ ▼
カスタム文字サイズ
\fontsize{6.5pt}{0pt}\selectfont
フォントサイズ:6.5pt 行送り:0pt
\fontsize{10pt}{20pt}\selectfont
フォントサイズ:10pt 行送り:20pt
\fontsize{15pt}{40pt}\selectfont
フォントサイズ:15pt 行送り:40pt
http://www.latex-cmd.com/style/size.html#size02
▲ ▼
ヘッダーフッター
http://osksn2.hep.sci.osaka-u.ac.jp/~naga/miscellaneous/tex/tex-tips1.html
▲ ▼
特殊文字
http://meta.wikimedia.org/wiki/Help:Displaying_a_formula/ja
http://www.h7.dion.ne.jp/~sappon/info/texsymbl.html
http://www002.upp.so-net.ne.jp/latex/kigou_all.html
▲ ▼
三点リーダを書く
http://utsukemononi.gozaru.jp/latex/datm031.html
▲ ▼
Texで数式を書く
\begin{eqnarray}
C &=& \sqrt[]{ \mathstrut 2 \int_0^H (-B) dz} \\
B &=& g[ \frac{\theta'}{\bar{\theta}} + 0.61q_v' - q_w ]
\end{eqnarray}
(上記の式は, Weisman and Rotunno, 2004, JAS の式を改変したものです. )
\begin{align*}
0 =
\left( \frac{u^2_{L,d}}{2} - \frac{u^2_{L,0}}{2} \right)
- \left( \frac{u^2_{R,d}}{2} - \frac{u^2_{R,0}}{2} \right)
- \int_0^d (w \eta)_d \, {\rm d}x
+ \int_0^H B_L \, {\rm d}z
\end{align*}
(上記の式は, Rotunno et al., 1988, JAS のコールドプールを導くための途中式です. )
▲ ▼
数式モードの行間を調整
\begin{eqnarray}
C &=& \sqrt[]{ \mathstrut 2 \int_0^H (-B) dz} \\ [-2pt]
B &=& g[ \frac{\theta'}{\bar{\theta}} + 0.61q_v' - q_w ]
\end{eqnarray}
\\のあとに[]で囲って何ポイントずらすかを設定できます。
▲ ▼
ベクトル表記
\usepackage{bm}
\bm{u}
▲ ▼
Texで数式を書く(Web版)
Webページ上でもTexの綺麗な数式が書けます。
TeXclip?
http://maru.bonyari.jp/texclip/texclip.php
Online Latex Equation Editor
http://www.sciweavers.org/free-online-latex-equation-editor
▲ ▼
分数のネスト
\[
f(x) = \frac{\displaystyle\int_0^1g(x)\,dx}{\displaystyle\int_0^1h(x)\,dx}
\]
f(x) = \frac{\displaystyle\int_0^1g(x)\,dx}{\displaystyle\int_0^1h(x)\,dx}
http://code.jasonbhill.com/latex/tips-for-latex-integrals/
▲ ▼
PDFにURLのリンクを作る
\usepackage[dvipdfmx]{hyperref}
とプリアンブルで宣言して、
\href{http://www.google.com}{ Googleのページ }
と書きます
http://www.str.ce.akita-u.ac.jp/~gotou/tebiki/texhtml.html#hyperref
▲ ▼
PDF作成時のしおりの文字化け対策
\usepackage[dvipdfm,bookmarks=true,bookmarksnumbered=true,bookmarkstype=toc]{hyperref}
\ifnum 42146=\euc"A4A2 \AtBeginDvi{\special{pdf:tounicode EUC-UCS2}}\else
\AtBeginDvi{\special{pdf:tounicode 90ms-RKSJ-UCS2}}\fi
をプリアンブルに書く。
http://www.nn.iij4u.or.jp/~tutimura/tex/dvipdfm.html#bookmark
▲ ▼
hyperref の Title が文字化けする場合の対処
\usepackage[dvipdfmx]{hyperref}
\usepackage{pxjahyper}
platex + dvipdfmx で,日本語を使用する場合は PXjahyper パッケージ を使用すればしおり・タイトル等の日本語の文字化けを防止できる
参考:http://oku.edu.mie-u.ac.jp/~okumura/texwiki/?hyperref
▲ ▼
LaTeX でコマンドや特殊文字等をそのまま記述する
\begin{verbatim}
$ git add *.f90 Makefile
$ git remote add origin user@192.168.1.1:/home/hoge/huga.git
$ git commit -m "hoge huga"
$ git push origin master
\end{verbatim}
▲ ▼
箇条書き
\begin{itemize}
\item ひとつ、おなかがすいた.
\item ふたつ、かふぇおれがすきだ.
\item みっつ、やっぱり気象がすきだ.
\end{itemize}
▲ ▼
箇条書き (数字)
\begin{enumerate}
\item ひとつ、どんなにつらくても
\item ふたつ、身体を大切にして
\item みっつ、自分を信じてやり抜け
\end{enumerate}
▲ ▼
注釈
http://www.latex-cmd.com/struct/footnote.html
▲ ▼
テキストをそのまま出力
http://medemanabu.net/latex/verb-verbatim/
▲ ▼
LATEX2HTML on Ubuntu 13.10
オリジナルソースと日本語化パッチを取ってくる。
$ wget http://www.latex2html.org/~latex2ht/current/latex2html-2008.tar.gz
$ wget http://takeno.iee.niit.ac.jp/~shige/TeX/latex2html/current/data/l2h-2K8-jp20110708.tar.gz
tar.gz ファイルをオリジナル、日本語化パッチの順に展開。
$ tar -zxvf latex2html-2008.tar.gz
$ tar -zxvf l2h-2K8-jp20110708.tar.gz
日本語化 patch を当てる
$ cd latex2html-2008
$ patch -p1 < l2h-2K8-jp2.1b1.13.patch
configure 時に、文字コードが utf8 であることを教えてあげる
$ ./configure --with-kanji=utf8
その後、make; make install でインストール完了
$ make
$ make check
$ make test
$ sudo make install
実行時は、一度 nkf -w8 でLaTeX文章を完全に utf8 化した後、latex2html に食わせると上手くいった。
$ nkf -w8 hoge.tex > huga.tex
$ latex2htlm huga.tex
http://www.latex2html.org/~latex2ht/current/
http://takeno.iee.niit.ac.jp/~shige/TeX/latex2html/current/l2h-current.html#pa_dist
▲ ▼
Yatex でコンパイル時に無限ループしてしまう
状況:コピーアンドペーストをした時に発生した
問題:参考文献に同じ名前のリンクが存在する
解決策:emacs のバッファを kill する
▲ ▼
List of acronyms の作成 (含 Glossary)
具体的なコマンドは,以下.
https://skalldan.wordpress.com/2011/08/13/abbreviations-with-latex/
http://texblog.org/2014/01/15/glossary-and-list-of-acronyms-with-latex/