![tikz 좌표로 상자 속성을 표현합니다.](https://rvso.com/image/328832/tikz%20%EC%A2%8C%ED%91%9C%EB%A1%9C%20%EC%83%81%EC%9E%90%20%EC%86%8D%EC%84%B1%EC%9D%84%20%ED%91%9C%ED%98%84%ED%95%A9%EB%8B%88%EB%8B%A4..png)
내 이해에 따르면 모든 LaTeX 상자에는 다음과 같은 기본 속성이 표시됩니다.
.. 그리고아무것LaTeX 상자에 포장되어 있습니다.
그래서 그림을 만들 때는 tikz
어떻게든 상자에 포장해야 합니다. 실제로 사용해 보면 이런 a height
와 a가 표시되는 것 같습니다 . 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)
만약 그렇다면 두 줄 사이의 수직 공간이 영향을 받을 수 있습니다.
\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}
휴!