LoginSignup
10
8

More than 5 years have passed since last update.

standaloneクラス

Last updated at Posted at 2016-10-11

standaloneクラス

TikZ などで図だけを作るときに便利なクラスファイル。
TeX Live や MikTeX にはもれなくついてくる。

基本的な使い方

TikZ で作った図を dvipdfmx を利用して PDF として出力する。

howtouse.tex
\documentclass[dvipdfmx,tikz]{standalone}

\begin{document}
\begin{tikzpicture}
\node[circle,draw] {Example};
\end{tikzpicture}
\end{document}

platex + dvipdfmx で,大きさが図とぴたり同じの PDF ファイルが得られる。
得られた PDF ファイルを別のファイルに \includegraphics で取り込んだり,
pdftocairo -png で png ファイルに変換したものを利用したりできる。

tikzpicture環境が複数ある場合

複数の tikzpicture 環境がある場合,
dvipdfmx を使わないのであれば
\documentclass[tikz]{standalone}
とすることで,各 tikzpicture 環境ごとに頁を変えた pdf ファイルが得られる。
しかし,
\documentclass[dvipdfmx,tikz]{standalone}
とするのは(私の手元では)うまくいかない。

複数の tikzpicture 環境を 1 頁にまとめた pdf ファイルを dvipdfmx を通して得るには,
documentclass のオプションに tikz を指定せず,\usepackage で TikZ を読み込む。

howtouse.tex
\documentclass[dvipdfmx]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node[draw] {Example};
\end{tikzpicture}
\begin{tikzpicture}
\node[circle,draw] {Example};
\end{tikzpicture}
\end{document}

これが最良の解決手段なのか,再確認しようね。>自分

こんな使い方も

mathexp.tex
\documentclass{standalone}

\begin{document}
$\displaystyle\sum_{k=1}^n k = \frac{n(n+1)}2$
\end{document}

別の文書に取り込めるような PDF ファイルが得られる。

参考

CTAN: https://www.ctan.org/pkg/standalone

10
8
0

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
10
8