0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

inkscape で数式入り画像pdf ファイルを作るには

Posted at

最近のLaTeXはpdfファイルを画像ファイルとしてincludeすることができる。pdfファイルの画像を作るには、tgif などでベクター画像からepsファイルを作って、そのファイルをpdf化することもいいが、inkscapeには、pdfファイルでテキストデータと画像データを分離して保存する機能がある。これを使った、数式入りpdfファイルの作り方を説明する。なお、このやり方はDebian 10 + inkscape + TeXLive で行っているが, python は使っていないはずなので、windowsでも同様のやり方が可能であると思われる。pythonが必要ないので、コマンドプロンプトの簡単な知識があれば、inkscapeのエクステンションを使うよりも簡単?に作業できると思われる。

inkscape でpdfファイルを作る

inkscapeで画像ファイルを作る。この際に、gnuplotでsvgデータを出力するなどで作るなんてこともできるだろう。注意すべき点は下記の通り

  • 数式を入力したいTextはTeXの数式同様に $$ 囲みにする。LaTeXコマンドを使いたい部分はそのコマンドをベタ打ちする。
  • ファイルを保存する時に pdf を指定する。そのときにText output options を「Omit text in PDF and create LaTeX file」とする

上記によって、hoge.pdf と hoge.pdf_tex の2つのファイルができる。

上記のpdfファイルを処理する

TeXのソースにもよるが、

\begin{figure}[htbp]
\centering
\def\svgwidth{20cm}
\input{hoge.pdf_tex}
\end{figure}

をソースに加えれば、数式部分をTeXで処理した画像が挿入される。ただ、これをそのまま使うのは、画像流用のときに面倒でもあるので、数式入り画像pdfファイルを作ってみる。

fuga.tex
\documentclass[dvipdfmx]{ujarticle}

\usepackage{graphicx,color}
\usepackage{newtxtext}
\usepackage[varg]{newtxmath}
\usepackage{mathrsfs}
\usepackage{bm}
\usepackage[noto-otc]{pxchfon}

\renewcommand{\vec}[1]{\bm{#1}}
\renewcommand{\kanjifamilydefault}{\gtdefault}

\begin{document}
\thispagestyle{empty}

\mathversion{bold}
\LARGE

\begin{figure}[htbp]
\centering
\def\svgwidth{20cm}
\input{hoge.pdf_tex}
\end{figure}

\end{document}

を作り、uplatex + dvipdfmx で pdf ファイルを作る。(中身のusepackageなどは適宜入れ替えれば良い)

pdfcrop で画像を切り取る

上記で得られた fuga.pdf は画像だけでなく、余白のあるpdfファイルである。これは使いづらいので、pdfcrop を用いて余白を切り抜く。

pdfcrop fuga.pdf final.pdf

とすることで、余白部分を切り抜いたfinal.pdfが出来上がる。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?