Created
January 20, 2023 12:28
-
-
Save h20y6m/30551e5676593c9a008ccd43087a5bde to your computer and use it in GitHub Desktop.
LaTeX: (u)pLaTeX + dvipdfmxで縦組みでtcolorboxを使ってみる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%#! ptex2pdf -u -l | |
% | |
% (u)pLaTeX + dvipdfmxで縦組みでtcolorboxを使ってみる。 | |
% | |
% 【警告】 | |
% 下記のコードはtcolorboxではなくTikZ/PGFのsystemlayerに変更を加えます! | |
% 最悪TikZ/PGF関連のすべてが壊れます! | |
% 「わかっている人」以外は使わないように! | |
% | |
% 【注意】 | |
% (u)pLaTeX + dvipdfmx専用です。 | |
% TikZ/PGFパッケージのバージョンに依存します。 | |
% | |
\documentclass[uplatex,dvipdfmx,tate,book,a5paper]{jlreq} | |
\usepackage{tcolorbox} | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
%%% !!! DANGER !!! DANGER !!! DANGER !!! DANGER !!! DANGER !!! DANGER !!! %%% | |
\iftrue | |
\usepackage{etoolbox} | |
\makeatletter | |
% | |
% 縦組みの場合は、描画全体を時計回りに90度回転します。 | |
% | |
\patchcmd{\pgfsys@beginpicture}{% | |
\special{pdf:bcontent}% | |
}{% | |
\special{pdf:bcontent}% | |
\iftdir% | |
\special{pdf:code 0 -1 1 0 0 0 cm}% | |
\fi% | |
}{}{\show\pgfsys@beginpicture}% | |
% | |
\patchcmd{\pgfsys@endpicture}{% | |
\special{pdf:econtent}% | |
}{% | |
\iftdir% | |
\special{pdf:code 0 1 -1 0 0 0 cm}% | |
\fi% | |
\special{pdf:econtent}% | |
}{}{\show\pgfsys@endpicture}% | |
% | |
% テキスト出力は全体の回転を打ち消すために反時計回りに90度回転します。 | |
% | |
\patchcmd{\pgfsys@hbox}{% | |
\box#1% | |
\pgfsys@dvipdfmx@stop@force@reset@color% | |
}{% | |
%% 反時計回りに90度回転します。 | |
%% どういうときに呼び出されるのか分からないので試していません。 | |
\iftdir% | |
\special{pdf:code 0 1 -1 0 0 0 cm}% | |
\fi% | |
\box#1% | |
\iftdir% | |
\special{pdf:code 0 -1 1 0 0 0 cm}% | |
\fi% | |
\pgfsys@dvipdfmx@stop@force@reset@color% | |
}{}{\show\pgfsys@hbox}% | |
% | |
\patchcmd{\pgfsys@hboxsynced}{% | |
\special{pdf:btrans matrix \pgf@pt@aa\space \pgf@pt@ab\space \pgf@pt@ba\space \pgf@pt@bb\space | |
\pgf@sys@tonumber{\pgf@pt@x} \pgf@sys@tonumber{\pgf@pt@y}}% | |
\box#1% | |
\special{pdf:etrans}% | |
\pgfsys@dvipdfmx@stop@force@reset@color% | |
}{% | |
\iftdir% | |
{% | |
%% 変換行列を変更します。 | |
%% よくわからないけどこれでうまくいくみたい。 | |
%% [aa ab ba bb x y] => [-ab aa -bb ba x y] | |
\@tempdima=\pgf@pt@ab pt% | |
\@tempdimb=\pgf@pt@bb pt% | |
\@tempdima=-\@tempdima% | |
\@tempdimb=-\@tempdimb% | |
\xdef\pgf@tempaa{\pgf@sys@tonumber{\@tempdima}}% | |
\xdef\pgf@tempab{\pgf@pt@aa}% | |
\xdef\pgf@tempba{\pgf@sys@tonumber{\@tempdimb}}% | |
\xdef\pgf@tempbb{\pgf@pt@ba}% | |
%% \typeout{\pgf@tempaa\space \pgf@tempab\space \pgf@tempba\space \pgf@tempbb\space}% | |
}% | |
\special{pdf:btrans matrix \pgf@tempaa\space \pgf@tempab\space \pgf@tempba\space \pgf@tempbb\space | |
\pgf@sys@tonumber{\pgf@pt@x} \pgf@sys@tonumber{\pgf@pt@y}}% | |
\else% | |
\special{pdf:btrans matrix \pgf@pt@aa\space \pgf@pt@ab\space \pgf@pt@ba\space \pgf@pt@bb\space | |
\pgf@sys@tonumber{\pgf@pt@x} \pgf@sys@tonumber{\pgf@pt@y}}% | |
\fi% | |
\box#1% | |
\special{pdf:etrans}% | |
\pgfsys@dvipdfmx@stop@force@reset@color% | |
}{}{\show\pgfsys@hboxsynced}% | |
% | |
\makeatother | |
\fi | |
%%% !!! DANGER !!! DANGER !!! DANGER !!! DANGER !!! DANGER !!! DANGER !!! %%% | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
\tcbuselibrary{breakable,raster,skins} | |
\definecolor{MyGrean}{RGB}{0,128,0} | |
\tcbset{ | |
enhanced, | |
breakable, | |
drop fuzzy shadow, | |
fonttitle=\bfseries, | |
colframe=MyGrean, | |
colback=MyGrean!10!white, | |
colbacktitle=MyGrean!30!white, | |
coltext=black, | |
coltitle=black, | |
} | |
\usepackage{bxjalipsum} | |
\begin{document} | |
\jalipsum[1-2]{wagahai} | |
\begin{tcolorbox}[title=吾輩は猫である$\displaystyle \int_{0}^{1} e^{x}\,dx$] | |
\jalipsum[3-4]{wagahai} | |
\end{tcolorbox} | |
\jalipsum[5-6]{wagahai} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment