LoginSignup
0
0

More than 1 year has passed since last update.

TeXの使い方メモ

Last updated at Posted at 2021-02-14

Ubuntu 20.04でTeXからpdfを作るためのメモ。

使い方

TeXをインストール

sudo apt install texlive-lang-cjk texlive-fonts-recommended \
  texlive-latex-recommended \ # ctable.sty
  texlive-latex-extra \ # mathdots.sty
  texlive-science # algorithm2e.sty

.tex から .pdf を生成

lualatex

TikZを使うならこれを使う必要がある。pdfが直接生成されて便利。

lualatex foo.tex

platex

# foo.dvi を作成
platex foo.tex

# foo.pdf を作成
dvipdfmx foo.dvi

文法

改行

\\ と書く。

インデント

\indent と書く。

アクセント

通常モードでは \'a\`a、mathモードでは \acute{a}\grave{a} を使う。

インライン数式

$数式$ と書く。

ブロック数式

\begin{align*}
  x
  &= y \\
  &= z \tag{1}
\end{align*}

という感じにすると=が揃えられ、一部にのみタグがつけられる。

分数

\frac{x}{y}

δx

\partial x

太字

\mathbf{x}

添字

x_i
\mathbf{x}_i

log

\log n
\log_x y

点リスト

\begin{itemize}
  \item foo bar
  \item baz
\end{itemize}

数字リスト

\begin{enumerate}
  \item foo bar
  \item baz
\end{enumerate}

オーマトン

TiKZを使う。 https://tex.stackexchange.com/questions/20784/which-package-can-be-used-to-draw-automata

LuaTeXじゃないと動かない。 lualatex foo.tex でコンパイルする。

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto] 
   \node[state,initial] (q_0)   {$q_0$}; 
   \node[state] (q_1) [above right=of q_0] {$q_1$}; 
   \node[state] (q_2) [below right=of q_0] {$q_2$}; 
   \node[state,accepting](q_3) [below right=of q_1] {$q_3$};
    \path[->] 
    (q_0) edge  node {0} (q_1)
          edge  node [swap] {1} (q_2)
    (q_1) edge  node  {1} (q_3)
          edge [loop above] node {0} ()
    (q_2) edge  node [swap] {0} (q_3) 
          edge [loop below] node {1} ();
\end{tikzpicture}
\end{document}

リファレンス

記号 TeX
\leq
\geq
\infty
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0