# pxpgftate Package **pLaTeX/upLaTeX: PGF/TikZ in the vertical (tate) direction with dvipdfmx and dvips** [日本語の説明は後半にあります。](#日本語) In the vertical (tate) direction of pTeX and upTeX, the DVI drivers place the characters rotated, but PGF draws its pictures in the unrotated page coordinate system. Without this package, pictures in tate text come out sideways, and shadings, patterns or fadings stop pLaTeX with ! Incompatible direction list can't be unboxed. With this package, a picture that begins in the tate direction is rotated like the surrounding text: its x-axis points in the direction of the line (downwards) and its y-axis points to the right. Text in nodes is typeset in the tate direction. The direction is determined at the beginning of each picture, so yoko boxes inside tate text keep working as before. Supported: * paths, nodes, transformations (`rotate`, `transform shape`), colors * shadings, patterns, fadings, transparency groups * `remember picture`, `overlay` and the `current page` node * tcolorbox (also `enhanced`, `breakable`, `drop shadow`) The package is meant for TeX Live 2012 up to the release of PGF that supports the tate direction natively. When the loaded PGF supports it already (it defines `\pgfsys@ptex@tate@supported`), the package does nothing. * **Supported formats/engines:** pLaTeX, upLaTeX (with dvipdfmx or dvips), TeX Live 2012 or later ## Files | File | Description | |---|---| | `pxpgftate.sty` | The package | | `pxpgftate.tex`, `pxpgftate.pdf` | Documentation | | `test-pxpgftate.tex` | Test document (`make test`) | ## Requirements * pLaTeX or upLaTeX (TeX Live 2012 or later) * PGF 2.10 or later * the `dvipdfmx` or `dvips` driver (with other drivers and other engines the package does nothing) ## Installation Copy `pxpgftate.sty` to your local TeX tree: `$TEXMF/tex/platex/pxpgftate/` ## Usage Load the package after `tikz` (or `pgf`): ```latex \documentclass[dvipdfmx]{tarticle} \usepackage{tikz} \usepackage{pxpgftate} \begin{document} 縦組みの文中の\tikz\draw[->](0,0)--(1,0);図。 \end{document} ``` Loading it before PGF works, too; the patches are then applied at `\begin{document}`. The package has no options. ## When PGF supports the tate direction itself Support for the tate direction has also been proposed for PGF itself ([pgf-tikz/pgf#1487](https://github.com/pgf-tikz/pgf/pull/1487)). Once a release of PGF includes it, PGF handles pictures in tate text by itself, and this package does nothing: it leaves PGF alone and only writes the following to the log: Package pxpgftate Info: PGF supports the tate direction itself. (pxpgftate) Nothing is done on input line .... So you can keep `\usepackage{pxpgftate}` in your documents: they work both with older TeX Live (where the package does the work) and with newer TeX Live (where PGF does it), and look the same. You may remove the line once you use only a PGF with the native support. ## What it changes The package wraps the driver macros of PGF instead of copying them, so the same code works with the different PGF versions of TeX Live 2012–2026: * `\pgfsys@beginpicture`, `\pgfsys@endpicture`: rotate the picture in the tate direction (dvipdfmx; dvips rotates PostScript specials by itself). * `\pgfsys@hbox`, `\pgfsys@hboxsynced`, `\pgfsys@transparencygroupfrombox`: undo the rotation around the current point for boxes and XObjects (dvipdfmx). This uses `pdf:bcontent` rather than `pdf:btrans`, which is misplaced inside `pdf:bcontent` and in XObjects with dvipdfmx before TeX Live 2021. With PGF 2.10 (TeX Live 2012), the box macros of PGF 3.0 are used in tate pictures. * `\pgfsys@getposition`, `current page`: rotate page positions into the coordinate system of a tate picture. * `\pgfutil@insertatbegincurrentpagefrombox`, `\pgfdeclarefading`, `\tikzfadingfrompicture`, `\tikzfading`: always use the yoko direction, since this material is unboxed at shipout in the yoko direction. * With LaTeX before 2020-10-01 and everyshi.sty v3: the shipout hooks are run in the yoko direction, as the pxeveryshi package does. This affects all users of everyshi.sty in tate documents (nothing is done when pxeveryshi is loaded). ## Limitations * Only the tate direction is handled; the `\dtou` direction is not. * Fadings are always defined in the yoko direction, also when they are declared in tate text. * `remember picture`, `overlay` and `current page` need the position tracking of PGF, which PGF enables for pLaTeX only from TeX Live 2018 on. This is the same in yoko documents. * With `dvips`, fadings need a PGF that supports them with dvips (not the one of TeX Live 2016 or earlier), and Japanese fonts need the usual font map setup for dvips and Ghostscript. Both are independent of this package. ## Testing * `make test` typesets `test-pxpgftate.tex` with the installed TeX Live (pLaTeX/upLaTeX × dvipdfmx/dvips) and checks that there are no errors and that pxpgftate patched the driver. * `make test-matrix` (`run-matrix.sh`, only in the repository) does the same with TeX Live 2012–2026 installed in `/opt/texlive/` and renders the first page of each result into `test-out/` for a visual check. ## History This package grew out of patches for PGF in the tate direction that the author has been developing since 2015 for book production with pLaTeX and dvipdfmx. In 2024 they were put together as `pgfsys-dvipdfmx-ptextate.sty` and two patched copies of `pgfutil-latex.def`. The package was then rewritten to patch PGF without replacing its files. * v1.0 (2026-11-04): first release ## Repository * * Bug reports: ## License This package may be distributed and/or modified under the [LaTeX Project Public License](https://www.latex-project.org/lppl.txt), version 1.3c or later, and/or under the GNU General Public License, version 2 or later, like PGF itself. See `LICENSE`. Copyright (c) 2015-2026 Munehiro Yamamoto --- ## 日本語 pLaTeX/upLaTeXの縦組み(tate)中で、`dvipdfmx`/`dvips`ドライバを使ってPGF/TikZを使えるようにするパッケージです。 pTeX/upTeXの縦組みでは、DVIドライバは文字を回転して配置しますが、PGFは回転していないページ座標系で図を描きます。そのため、このパッケージなしでは縦組み中の図が横倒しになり、シェーディング・パターン・フェードを使うと `Incompatible direction list can't be unboxed` エラーで止まります。 このパッケージを読み込むと、縦組み中で始まった図は周囲の文字と同じように回転します(x軸は行送りの方向=下向き、y軸は右向き)。ノード内の文字は縦組みで組まれます。組方向は図ごとに判定するので、縦組み中のyoko箱の図も従来どおり動きます。 対応しているもの: * パス、ノード、座標変換(`rotate`、`transform shape`)、色 * シェーディング、パターン、フェード、透明グループ * `remember picture`、`overlay`、`current page` ノード * tcolorbox(`enhanced`、`breakable`、`drop shadow` を含む) 対象はTeX Live 2012から、PGF本体が縦組みに対応する版の手前までです。読み込んだPGFが縦組みに対応済み(`\pgfsys@ptex@tate@supported` が定義されている)なら、このパッケージは何もしません。 ### 使い方 `tikz`(または `pgf`)の後で読み込みます。 ```latex \documentclass[dvipdfmx]{tarticle} \usepackage{tikz} \usepackage{pxpgftate} ``` PGFより前に読み込んでも構いません。その場合は `\begin{document}` の時点でパッチを当てます。オプションはありません。 ### PGF本体が縦組みに対応したら 縦組み対応は、PGF本体にも提案しています([pgf-tikz/pgf#1487](https://github.com/pgf-tikz/pgf/pull/1487))。これを取り込んだPGFが出ると、縦組み中の図はPGFだけで正しく描かれ、このパッケージは何もしなくなります。PGFには手を加えず、ログに次の情報を書くだけです。 Package pxpgftate Info: PGF supports the tate direction itself. (pxpgftate) Nothing is done on input line .... そのため、文書の `\usepackage{pxpgftate}` は残したままで構いません。古いTeX Liveではこのパッケージが、新しいTeX LiveではPGF本体が縦組みを扱い、どちらでも同じ結果になります。PGF本体の対応版だけを使うようになったら、この行は消しても構いません。 ### 仕組み PGFのドライバのマクロをコピーせずにラップしているので、TeX Live 2012〜2026の各版のPGFで同じコードが動きます。PGFのファイルを差し替えることはしません。箱やXObjectの逆回転には `pdf:btrans` ではなく `pdf:bcontent` を使います(TeX Live 2020以前のdvipdfmxでは、`pdf:bcontent` の中やXObjectの中で `pdf:btrans` の位置がずれるため)。PGF 2.10(TeX Live 2012)では、縦組みの図の中に限ってPGF 3.0の箱のマクロを使います。LaTeX 2020-10-01より前でeveryshi.sty v3を使う場合は、pxeveryshiと同様にshipoutフックを横組み方向で実行します(縦組み文書中のeveryshi利用者すべてに影響します。pxeveryshiが読み込まれていれば何もしません)。 ### 制限 * 扱うのはtate方向だけで、`\dtou` 方向には対応していません。 * `remember picture`、`overlay`、`current page` にはPGFの位置追跡が必要です。PGFがpLaTeXで位置追跡を有効にするのはTeX Live 2018以降です(横組み文書でも同じです)。 * フェードは、縦組み中で宣言しても常に横組み方向で定義します。 * `dvips` でのフェードには、dvipsでフェードに対応したPGF(TeX Live 2017以降)が必要です。和文を出すには、dvipsとGhostscriptの通常の和文フォント設定も必要です(どちらもこのパッケージとは無関係です)。 ### テスト * `make test`:インストール済みのTeX Liveで `test-pxpgftate.tex` を pLaTeX/upLaTeX × dvipdfmx/dvips で組み、エラーがないこととドライバへのパッチを確認します。 * `make test-matrix`(`run-matrix.sh`、リポジトリのみ):`/opt/texlive/<年>` のTeX Live 2012〜2026で同じことを行い、各結果の1ページ目を `test-out/` に画像化します。 ### ライセンス Copyright (c) 2015-2026 Munehiro Yamamoto PGFと同じく、LaTeX Project Public License 1.3c以降、またはGNU General Public License 2以降のもとで配布・改変できます。