
我正在使用 製作海報beamerposter
。塊內的文字似乎總是沒有左邊距。誰能告訴我一種在塊中引入左邊距的方法?
這是塊外觀的範例。請注意,文字開始時沒有左邊距。
如果您能告訴我如何定義區塊內的左、右、上、下邊距,那就太好了。請注意,我有巢狀區塊,儘管巢狀區塊具有不同的環境名稱(我稱為 then insideBlocks
)。因此,我不希望環境的利潤block
會影響我的insideBlocks
環境的利潤。
希望我說清楚了。
答案1
我認為這可以透過多種方式實現。一種可能性是定義一個具有自訂邊距的新區塊環境,如下所示:
\documentclass{beamer}
\usetheme{Frankfurt}
\newenvironment<>{myblock}[1]{%
\begin{actionenv}#2%
\def\insertblocktitle{\leftskip=10pt\rightskip=10pt\vspace{10pt} #1\vspace{10pt}}%
\par%
\usebeamertemplate{block begin}\leftskip=10pt\rightskip=10pt\vspace{10pt}}
{\par\vspace{10pt}\usebeamertemplate{block end}
\end{actionenv}}
\begin{document}
\begin{frame}
\begin{myblock}{example title to show 10pt up, down, left and right margins}
example text to show 10pt up, down, left and right margins
\end{myblock}
\begin{block}{example title to show standard margins}
example text to show standard margins
\end{block}
\end{frame}
\end{document}
在新環境(我稱之為myblock
)中\leftskip
,\rightskip
和\vspace
都是用來設定邊距的。作為範例,我將所有內容設定為 10pt。如果您不需要,例如右邊距,只需rightskip
從程式碼中刪除。我假設您還想自訂標題文字邊距,如果您不想僅從leftskip
中刪除等\def\insertblocktitle{}
。結果是:
另一種可能性是使用tcolorbox
包,它可以讓您設定邊距,如下所示:
\documentclass{beamer}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\tcbset{ % custom tcolorbox
skin=enhanced,
frame style={fill=blue}, % sets the frame color
bottom=10pt, % distance between the body text and the bottom frame
top=10pt, % distance between the body text and the top frame
left=10pt,
right=10pt,
boxrule=0pt, % frame width
bottomtitle=10pt, % distance between the title text and the bottom title frame
toptitle=10pt, % distance between the title text and the top title frame
lefttitle=10pt, % title text left margin
righttitle=10pt
}
\begin{document}
\begin{frame}
\begin{tcolorbox}[title=test]
test
\end{tcolorbox}
\end{frame}
\end{document}
結果是:
編輯:我沒有beamerposter
在範例程式碼中添加該包,因為它在修改beamer
和beamerposter
不修改的情況下都可以工作。
答案2
您可以使用即將推出的 tcolorbox 內部主題 v0.3 版本(https://www.ctan.org/pkg/beamertheme-tcolorbox)。使用此主題,巢狀區塊將自動比周圍的區塊小一點:
\documentclass{beamer}
\usetheme{Warsaw}
\usepackage[size=a4,orientation=portrait]{beamerposter}
\useinnertheme{tcolorbox}
\begin{document}
\begin{frame}
\begin{block}{title}
content...
\begin{block}{title}
content...
\end{block}
\end{block}
\end{frame}
\end{document}