雑記 - inkscape Diff

  • Added parts are displayed like this.
  • Deleted parts are displayed like this.

!TexText extension
https://github.com/textext/textext/releases

LaTeX な数式を埋め込むための extension で、inkscape 1.3.x に対応しているのは最新の textext-1.9.0 以降。
source をとってきて、
python3 ./setup.py   (Linuxの場合)
すればよい。install される extension は ~/.config/inkscape/extensions/ 内。古い textext (1.8等) + inkscape 1.3 で数式を埋め込もうとすると固まるので、古い version はよしなに処理するのが吉。
なお LaTeX 環境が使えることは前提。

使い方: inkscape の extension → text → TexText で開くパネル内に、$\Delta$ のように入力すればよい。

!TexText extension 日本語の処理
標準の TexText extension は tex -> pdf のために "pdflatex" か "xelatex" か "lualatex"を用いるようになっている。(変数 tex_command)

pdflatex (pdftex) で日本語が入っていると「LaTeX Error: Unicode character あ (U+3042)」みたいなのが出てしまう。
日本語処理をできるようにするには、pdflatex ではなく、platex & dvipdfmx を使うように extension の python script を手直しすればよい。(もちろん platex と dvipdfmx が使えるという前提です。)例えば以下のように修正すれば当方ではうまくいきました。
--- .config/inkscape/extensions/textext/base.py.bkup 2023-09-13 12:21:24.994136638 +0900
+++ .config/inkscape/extensions/textext/base.py 2023-10-10 14:33:10.244445200 +0900
@@ -560,7 +560,9 @@
  
              # Exec tex_command: tex -> pdf
              try:
-                exec_command([tex_command, self.tmp('tex')] + self.LATEX_OPTIONS)
+#                exec_command([tex_command, self.tmp('tex')] + self.LATEX_OPTIONS)
+                exec_command(['platex', self.tmp('tex')])
+                exec_command(['dvipdfmx', self.tmp('dvi')])
              except TexTextCommandFailed as error:
                  if os.path.exists(self.tmp('log')):
                      parsed_log = self.parse_pdf_log()
 差分パッチ→ {{attach_anchor('inkscape_textext_ja.patch')}}

!eps 保存前に
対象とするオブジェクトを選択した後、「編集→ページサイズを選択オブジェクトに合わせる」をするとよい
(tex に貼り付ける際に座標がずれるのを防げる)

!Inkscape 1.4.2 (ebf0e940d0, 2025-05-08) で textext
Inkscape 1.4.2 で textext を使うには、textext の新しい version をいれる必要がある(1.11.1 2025.07 時点で最新の textext-1.11.1 を入れた)

inkscape を起動して、extension -> text -> textext を選ぶと、パネル内に以下の表示が表示:
Traceback (most recent call last):
(中略)
ModuleNotFoundError: No module named 'tinycss2'
tinycss2 module が存在しないということらしいので、
pip3 install tinycss2
を実行して再度 inkscape を起動すれば ok