Last active
December 28, 2025 16:04
-
-
Save yarakos95/db3c82385811eccef5f0e53b0d1b8917 to your computer and use it in GitHub Desktop.
TikZを利用してluatexjaマニュアルの図14のようなボックスを再現する[LaTeX]
This file contains hidden or 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
| %% The MIT License Copyright (c) 2025 Yarakashi Kikohshi | |
| %% TikZを利用することを前提とする | |
| %% \outbox*{<ボックスの数>}{<ボックスに囲われる文字>}[<tikzmarkのための座標名>] | |
| %% \outbox{3}{あいうえお} とすることで、`あいう' までボックスで囲われる。`えお' はこれに続く。 | |
| %% 折り返しには対応していない | |
| %% \outbox* とすることで、先頭のボックスに ■ の背景を与える | |
| %% 任意の場所に ■ 背景を与えるようにはしていない | |
| %% \outbox{}{}[A] とすることで、tikzmark を介して外部に座標名を提供する | |
| %% この場合の座標名は outboxA となる | |
| %% 加えて左端辺の上下中央にドットと短い水平線を与える | |
| \definecolor{b_cyan}{rgb}{0.70, .92, 98} | |
| \NewDocumentCommand{\outbox}{ s m m o }{% | |
| \noindent | |
| \begin{tikzpicture}[baseline=(text.base), remember picture] | |
| \begin{scope}[overlay, yshift=-0.12\zw, color=b_cyan] | |
| \node[draw=b_cyan, line width=.4pt, | |
| minimum width=1\zw, minimum height=1\zw, | |
| inner sep=0pt] (c1) | |
| at (0,0) {}; | |
| \IfBooleanT{#1}{\node[minimum size=0.7\zw, fill] {};} | |
| \draw[line width=.4pt] ($(c1.south west)+(0.5\zw,0)$) -- ++(0,0.2\zw); | |
| \foreach \i in {2,...,#2} { | |
| \node[draw=b_cyan, line width=.4pt, | |
| minimum width=1\zw, minimum height=1\zw, | |
| inner sep=0pt] (c\i) | |
| at ({(\i-1)*1\zw},0) {}; | |
| \draw[line width=.4pt] ($(c\i.south west)+(0.5\zw,0)$) -- ++(0,0.2\zw); | |
| } | |
| \IfNoValueF{#4} | |
| { | |
| \fill (c1.west) circle[radius=.1\zw]; | |
| \draw[line width=.4pt] | |
| ($(c1.west)+(-.5\zw,0)$) -- (c1.west); | |
| \coordinate[remember picture] (outbox#4) at (c1.west); | |
| } | |
| \end{scope} | |
| \node[anchor=north west, inner sep=0pt] (text) | |
| at (c1.north west) {#3}; | |
| \end{tikzpicture} | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
特に意味のない例: