![tikz座標でボックスのプロパティを表現する](https://rvso.com/image/328832/tikz%E5%BA%A7%E6%A8%99%E3%81%A7%E3%83%9C%E3%83%83%E3%82%AF%E3%82%B9%E3%81%AE%E3%83%97%E3%83%AD%E3%83%91%E3%83%86%E3%82%A3%E3%82%92%E8%A1%A8%E7%8F%BE%E3%81%99%E3%82%8B.png)
私の理解では、どの LaTeX ボックスにも次のような基本的なプロパティが表示されます。
.. そして何でもLaTeX ボックスにラップされます。
したがって、tikz
画像を生成するときは、何らかの方法でそれをボックスにラップする必要があります。実際、これを使用すると、このようなheight
と が表示されるようですbaseline
。たとえば、次のコード:
\documentclass{report}
\usepackage[english]{babel}
\usepackage{tikz}
\tikzset{x=1pt, y=1pt, z=1pt}
\begin{document}
\newcommand{\mypicture}{\begin{tikzpicture}
\node (a) at (0, 0) {\strut$a$};
\node (b) at (30, 0) {\strut$b$};
\draw[->] (a) .. controls (15, -20) and (30, -30) .. (b);
\end{tikzpicture}}
In my rather long, multilined text, I wish I could insert \mypicture{} just
as if it were something natural..
\end{document}
生成:
.. これで私の言いたいことが明確になったと思います。\mypicture
ボックスのベースラインがノードのベースラインと一致していないため、上記の挿入はまったく自然ではありません(a)
。また、一致すると、2 行間の垂直方向のスペースが影響を受ける可能性があります。
これを、手作業で調整せずに修正する方法は\raisebox
、\vspace
等?
tikz
すべての画像ボックスのプロパティを座標で表現するにはどうすればよいですかtikz
?
答え1
この場合、TikZ に、配置したい場所を指定する必要がありますbaseline
。ここでは、たとえば(a)
ノード上に配置したいとします。
これを提供するコードは次のとおりです:
\documentclass{report}
\usepackage[english]{babel}
\usepackage{tikz}
\tikzset{x=1pt, y=1pt, z=1pt}
\begin{document}
\newcommand{\mypicture}{\begin{tikzpicture}[baseline=(a.base)]
\node (a) at (0, 0) {\strut$a$};
\node (b) at (30, 0) {\strut$b$};
\draw[->] (a) .. controls (15, 20) and (30, 30) .. (b);
\end{tikzpicture}}
In my text, insert \mypicture{} just as if it were something natural..
\end{document}
そしてその結果は:
役に立つと幸いです。
答え2
私が必要としていた一般的な解決策は、両方の組み合わせbaseline
と素晴らしい鍵でしたuse as bounding box
。これを考慮してください:)
\documentclass[a4paper, 12pt]{report}
\usepackage{tikz}
\tikzset{x=1pt, y=1pt, z=1pt}
\begin{document}
\def\myfig{\begin{tikzpicture}[baseline=(base)] % choose baseline
% box dimensions
\path[draw, use as bounding box] (0, 0) rectangle (10, 15);
% set baseline
\coordinate (base) at (0, 5);
% actual content
\path[fill=blue] (0, 0) % a random path
.. controls (10, 10)
and (10, -10) ..
(10, 20) -- cycle;
% visualize baseline
\draw (0, 5) -- (10, 5);
\end{tikzpicture}}
Now I can define \emph{every} frea\myfig ng property of my tikz box!
\end{document}
ふう!