TeX
行列
\begin{equation}
\left[
\begin{array}{rr}
a_{11} & a_{12} \\
a_{21} & a_{22} \\
\end{array}
\right]
\left[
\begin{array}{rr}
X_1 \\
X_2 \\
\end{array}
\right]
+
\left[
\begin{array}{rr}
F_{1} \\
F_{2} \\
\end{array}
\right]
=
\left[
\begin{array}{rr}
X_{1} \\
X_{2} \\
\end{array}
\right]
\end{equation}
\begin{equation} \left[ \begin{array}{rr} a_{11} & a_{12} \\ a_{21} & a_{22} \\ \end{array} \right] \left[ \begin{array}{rr} X_1 \\ X_2 \\ \end{array} \right] + \left[ \begin{array}{rr} F_{1} \\ F_{2} \\ \end{array} \right] = \left[ \begin{array}{rr} X_{1} \\ X_{2} \\ \end{array} \right] \end{equation}
数式の改行
\usepackage{amssymb,amsmath} %使いそうなスタイルファイル
\begin{document}
\begin{equation*}
\begin{split} %これで数式を囲んでおく
X - AX &= F \\ %揃えたいところに&を入れて\\で改行
(I - A) X &= F \\
X &= (I - A)^{-1} F
\end{split}
\end{equation*}
\end{document}
\begin{equation*} \begin{split} %これで数式を囲んでおく X - AX &= F \\ %揃えたいところに&を入れて\\で改行 (I - A) X &= F \\ X &= (I - A)^{-1} F \end{split} \end{equation*}
TeXのフォント
TeXで特に指定してなければ本文は「Computer Modern Roman 10pt (cmr10)」が,
数式は「Computer Modern Math Italic 10pt (cmmi10)」になってます.
図なんかに使いたい場合は,ダウンロードして使えます.
ttf形式ならhttps://ctan.org/tex-archive/fonts/cm/ps-type1/bakoma/ttf/
otf形式ならhttps://ctan.org/tex-archive/fonts/cm/ps-type1/bakoma/otf/
手書き数式をTeXに
表の結合したセルを結合
\usepackage{multirow}
\begin{document}
\begin{table}[h]
\begin{tabular}{|c|c|c|} \hline
\multicolumn{2}{c}{\multirow{2}{*}{2列の2行を結合}}
& 1行3列
\\ \hline
& & 2行3列
\\ \hline
\end{tabular}
\end{table}
\end{document}
| 2列の2行を結合 | 1行3列 | |
|---|---|---|
| 2行3列 | ||
表のセルを縦に結合
\usepackage{multirow}
\begin{document}
\begin{table}[h]
\begin{tabular}{|c|c|c|} \hline
\multirow{2}{*}{2行を結合}
\\ \hline
& 2列 & 3列
\\ \hline
\end{tabular}
\end{table}
\end{document}
| 2行を結合 | 1行2列 | 1行3列 |
|---|---|---|
| 2行2列 | 2行3列 |
表のセルを横に結合
\begin{table}[h]
\begin{tabular}{|c|c|c|} \hline
\multicolumn{3}{c}{3列を横に結合}
\\ \hline
1列 & 2列 & 3列
\\ \hline
\end{tabular}
\end{table}
| 3列を横に結合 | ||
|---|---|---|
| 1列 | 2列 | 3列 |
bibtexのコンパイル
TeXLiveの場合は以下
platex hoge pbibtex hoge platex hoge
要はhoge.texは2回コンパイルが必要.
styの生成
MacのTeXのstyファイルの場所
なければ作る
mkdir -p -v /Users/$USER/Library/texmf/tex/latex
あれば開く
open Users/$USER/Library/texmf/tex/latex
表の横罫線のセルの間を開ける
\begin{table}[h]
\begin{center}
\caption{木製治山ダムとコンクリート製治山ダム建設のGHG排出量}
\begin{tabular}{lrrp{1pt}rr} \hline %p{1pt}で狭いセルを入れる
\multicolumn{1}{c}{ } &
\multicolumn{2}{c}{木製治山ダム} && %狭いセルには無記入
\multicolumn{2}{c}{コンクリート製治山ダム}
\\
\cline{2-3} \cline{5-6} %clineで狭いセル以外に罫線を入れる
\multicolumn{1}{c}{ } &
\multicolumn{1}{c}{直接エネルギー消費} &
\multicolumn{1}{c}{直接GHG排出量} &&
\multicolumn{1}{c}{直接エネルギー消費} &
\multicolumn{1}{c}{直接GHG排出量}
\\
\multicolumn{1}{c}{ } &
\multicolumn{1}{c}{(GJ)} &
\multicolumn{1}{c}{(t-CO$_2$eq)} &&
\multicolumn{1}{c}{(GJ)} &
\multicolumn{1}{c}{(t-CO$_2$eq)}
\\ \hline
直接効果 & 189.00 & 13.17 && 88.98 & 6.20 \\
間接効果 & 292.19 & 41.63 && 174.16 & 142.81 \\
2次波及効果 & 120.56 & 22.09 && 60.09 & 11.01 \\
総合効果 & 601.75 & 76.89 && 323.23 & 160.02 \\
\hline
\end{tabular}
\\
\end{center}
\end{table}
字下げしない
\noindent %部分的に字下げしない \parindent = 0pt %全部の段落で字下げしない
Unicodeに含まれていない文字のエラー
TeX live 2017 まではUnicode に含まれていない漢字があると,そこが空白になっていたんだけど,
Tex Live 2019 からは下記エラーが出るようになった.
! Package inputenc Error: Invalid UTF-8 byte "AD.
このエラーのときは,旧字を使わなければ(德 → 徳)エラーが回避できる.
どうしても使いたい場合は,
\documentclass[a4j]{jsarticle}
\usepackage{otf}
\begin{document}
\UTF{5fb7}%UTFは必ず大文字で
%これで文字コードからの出力が可能
\end{document}
出力
德
TeX Live には「OTF」パッケージが含まれているので,そのまま\usepackage{otf}が使える.
Unicodeを調べたい場合は,下記サイト.
グリフウィキ
Unicodeエスケープシーケンス変換ツール
OTFパッケージについては下記.
OTFパッケージについて
*2004年と古いので各リンクは切れているが,勉強にはなる(と思う).
multicolsで図表の貼り付け
途中から2段組にしたいときなど,multicolsを使うけど, \begin{figure}で図表の貼り付けができないので以下の感じ. ただし,これでやると結構空白ができる
\makeatletter
\newenvironment{tablehere}
{\def\@captype{table}}
{}
\newenvironment{figurehere}
{\def\@captype{figure}}
{}
\makeatother %\begin{document}の前に書く
\begin{document}
\begin{figurehere} %図の場合
\includegraphics[width=7cm,pagebox=cropbox,clip]{hoge.pdf}
\gt \caption{hoge}
\label{hoge}
\end{figurehere}
\begin{tablehere} %表の場合
~~
\end{tablehere}
\end{document}
PDFで図表を貼り付け
jpgとかepsとかで図表を貼り付けるより処理が早い.
\documentclass[a4j]{jsarticle}
\usepackage[dvipdfmx]{graphicx}
\begin{document}
hogeを{\bf 図--\ref{sansyou}}に示した.
\begin{figure}[h]
\includegraphics[width=15cm,pagebox=cropbox,clip]{hoge.pdf}
\label{sansyou} %図の参照(\ref{sansyou})
\caption{タイトル} %図のタイトル
\end{figure}
\end{document}
TeX辞書
1行の中で左揃え,右揃え
\begin{flushleft} 左揃え \end{flushleft}
\begin{flushright} 右揃え \end{flushright}
だと,右揃えが次の行にいってしまうので,
\noindent 左揃え \hfill 右揃え
を使えば1行の中で左右に揃えられる.
こっちもあり?むしろこっち?
左側 \hskip 1zw \hfill 右側
簡単な余白設定
%geometryパッケージを使用
¥usepackage[top=20truemm,bottom=20truemm,left=25truemm,right=25truemm]{geometry}
%この状態だと
%topが上余白, 20 mm
%bottomが下余白,20 mm
%leftが左余白,25 mm
%rightが右余白,25 mm
好きなPart, Section 等番号から始める
%始めたい番号の前の番号を入力
\setcounter{part}{3}
\setcounter{section}{2}
\part{第4部から始まる}
\section{3章から始まる}
URLを入力する
%urlパッケージを使用
\usepackage{url}
%URLの入力
\url{http://huzita.starfree.jp/dokuwiki/}
参考文献の番号スタイル変更
%デフォルトでは
文章\cite{1},引用\cite{1,2}
\begin{thebibliography}{9}
\bibitem{1} 文献1
\bibitem{2} 文献2
\end{thebibliography}
出力
文章[1],引用[1, 2]
[1] 文献1
[2] 文献2
%上付き片括弧にするには
\makeatletter
\renewcommand{\@cite}[1]{\textsuperscript{#1)}}
\renewcommand{\@biblabel}[1]{#1)}
\makeatother
\begin{document}
文章\cite{1},引用\cite{1,2}
\begin{thebibliography}{9}
\bibitem{1} 文献1
\bibitem{2} 文献2
\end{thebibliography}
出力
文章$^{1)}$,引用$^{1, 2)}$
1) 文献1
2) 文献2
下線を入れる
TeXで\underline{下線}を入れる
TeXで下線を入れる

