基本上我想要两个 tikzpictures大小相同对齐两列。为了实现这一点,我使用了tcolorbox
带有\tcbsidebyside{}
命令的包。问题是第二列的图片大小不对,我不知道为什么。
如何在 -command 的帮助下获取两个大小相同且之间有较小间隙的 tikzpicture
\tscsidebyside
?
在下面的图片中,绿色框显示了我正在寻找的内容……
平均能量损失
\documentclass[12pt, a4paper, parskip=full]{scrartcl}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
\tcbsidebyside[
sidebyside adapt=left,
blanker,
sidebyside gap=0.5\baselineskip,
sidebyside align=top seam
]
{
\begin{tikzpicture}[scale=\linewidth/20cm]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
}
{
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
\tcbsidebyside[
sidebyside adapt=left,
blanker,
sidebyside gap=0.5\baselineskip,
sidebyside align=top seam
]
{
\begin{tikzpicture}[scale=\linewidth/20cm]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
}
{
\begin{tikzpicture}[scale=\linewidth/20cm]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
}
\end{document}
答案1
\tcbsidebyside 内部更改 \linewidth,并且由于您使用的是sidebyside adapt=left
,因此两侧不会以相同的方式受到影响。最好使用独立的长度进行缩放。
\documentclass[12pt, a4paper, parskip=full]{scrartcl}
\usepackage{tikz}
\usepackage[most]{tcolorbox}
\newlength\mylinewidth
\AtBeginDocument{\mylinewidth=\linewidth\relax}
\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
\tcbsidebyside[
sidebyside adapt=left,
blanker,
sidebyside gap=0.5\baselineskip,
sidebyside align=top seam
]
{
\begin{tikzpicture}[scale=\mylinewidth/20cm]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
}
{
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
\tcbsidebyside[
sidebyside adapt=left,
blanker,
sidebyside gap=0.5\baselineskip,
sidebyside align=top seam
]
{
\begin{tikzpicture}[scale=\mylinewidth/20cm]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
}
{
\begin{tikzpicture}[scale=\mylinewidth/20cm]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
}
\end{document}
答案2
虽然这个答案没有\tscsidebyside
按照原作者明确要求的那样使用,但我还是将其保留为一个可能对其他读者有用的参考。
原始答案
您不需要将 tcolorbox 仅用于并排放置事物。您可以使用\parbox
或其他标准 latex 环境将文本块并排放置,并且您不需要任何特殊环境来并排放置 tikzpictures,而只需在需要时调整图形的基线即可。
有关详细信息,请参阅For more info, see这个问题, 或者这个答案以及以下 MWE:
\documentclass[12pt, a4paper, parskip=full]{scrartcl}
\usepackage{tikz}
\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
\begin{tikzpicture}[scale=\textwidth/20cm, baseline=(current bounding box.north)]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}\hspace{1mm}
\parbox[t]{0.5\textwidth}{\vskip0pt
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
\begin{tikzpicture}[scale=\linewidth/20cm]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}\hspace{1mm}
\begin{tikzpicture}[scale=\linewidth/20cm]
\draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
\draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
\draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
\end{tikzpicture}%
\end{document}