我怎样才能在一页中设置 2 个 tcbposter?并为每个 tcbposter 设置它们的绝对位置 (x,y)?
最少编码
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{poster}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\begin{tcbposter}[
poster = {
columns=1,
rows=2,
spacing=3mm,
height=14cm,
width=6cm,
},
]
\posterbox[
colframe = red,
width=5cm, height= 10cm
]{ }{\includegraphics[width=3cm]{example-image-a}}
\end{tcbposter}
\begin{tcbposter}[
poster = {
columns=1,
rows=2,
spacing=3mm,
height=14cm,
width=6cm,
},
]
\posterbox[
colframe = blue,
width=5cm, height= 10cm
]{ }{\includegraphics[width=3cm]{example-image-b}}
\end{tcbposter}
\end{document}
预先感谢
答案1
1. 将两张海报放在同一页上:
只是不要在两张海报之间留下空行。
事实上,使用 TeX 和 LaTeX 时,空行会被解释为一个新段落。因此,这两张海报被放在两个连续的段落中。
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{poster}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\begin{tcbposter}[
poster = {
columns=2,
rows=2,
spacing=3mm,
height=14cm,
width=6cm,
},
]
\posterbox[
colframe = red,
width=5cm, height= 10cm
]{ }{\includegraphics[width=3cm]{example-image-a}}
\end{tcbposter}% <- delete blank ligne
\begin{tcbposter}[
poster = {
columns=1,
rows=2,
spacing=3mm,
height=14cm,
width=6cm,
},
]
\posterbox[
colframe = blue,
width=5cm, height= 10cm
]{ }{\includegraphics[width=3cm]{example-image-b}}
\end{tcbposter}
\end{document}
2. 我建议张贴这两张海报:
我建议不要将两张海报并排放置,而只放置其中一张,其大小与去掉顶部、底部、左侧和右侧边距的整个页面大小相同。
coverage = {spread,left=0pt,right=0pt,top=0pt,bottom=0pt},
然后我们在其中放置你想要放置的两个框。第一个带有{xshift=1cm,yshift=-2cm }
,第二个带有{xshift=7cm,yshift=-5cm }
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[poster]{tcolorbox}
\pagestyle{empty}
\begin{document}
\begin{tcbposter}[
coverage = {spread,left=0pt,right=0pt,top=0pt,bottom=0pt},
poster = {showframe,
columns=1,
rows=1,
rowspacing=0pt,
colspacing=0pt,
},
]
\posterbox[
colframe = red,
width=5cm, height= 10cm
]{xshift=1cm,yshift=-2cm }{\includegraphics[width=3cm]{example-image-a}}
\posterbox[
colframe = blue,
width=5cm, height= 10cm
]{xshift=7cm,yshift=-5cm }{\includegraphics[width=3cm]{example-image-b}}
\end{tcbposter}
\end{document}
3. 随附textpos
包装
我不想使用允许您在页面中精确放置框的 Tikz 参数,因为它需要您编译两次,这是一个问题,特别是当您的文档很复杂时。
我使用另一个包(textpos
),它允许将文本放置在页面的绝对位置,而 LaTeX 通常不允许这样做,因为它旨在为我们管理框间距。
最终结果的代码如下:
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[poster]{tcolorbox}
\usepackage[absolute%,showboxes
]{textpos}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
\pagestyle{empty}
\begin{document}
\begin{textblock}{6}(1,2)
\begin{tcbposter}[
coverage = {left=0pt,right=0pt,top=0pt,bottom=0pt},
poster = {
columns=1,
rows=2,
spacing=3mm,
height=14cm,
width=6cm,
},
]
\posterbox[
colframe = red,
width=5cm, height= 10cm
]{ }{\includegraphics[width=3cm]{example-image-a}}
\end{tcbposter}
\end{textblock}
\begin{textblock}{6}(7,5)
\begin{tcbposter}[
coverage = {left=0pt,right=0pt,top=0pt,bottom=0pt},
poster = {
columns=1,
rows=2,
spacing=3mm,
height=14cm,
width=6cm,
},
]
\posterbox[
colframe = blue,
width=5cm, height= 10cm
]{ }{\includegraphics[width=3cm]{example-image-b}}
\end{tcbposter}
\end{textblock}
\end{document}
使用 www.DeepL.com/Translator 翻译