我正在使用该tcolorbox
软件包在文档中生成一些块。我使用 beamer 和 beamerarticle 生成幻灯片和与演示文稿相关的一种手稿。
如果您查看下面的图片,您会发现,无论是在文章模式还是在 beamer 模式中,在example block
beamer 环境中的块中,文本开头都有一个空格tcolorbox
。如果我直接使用,该空格似乎不存在tcolorbox
。有没有办法删除它?
这是投影机模式下的样子,您可以看到空间。
这就是它在文章模式下的样子。比较这两个块,第一个在外面example block
(直接用 tcolorbox,没有空格),第二个在里面example block
(有空格)。
以下是产生上述两幅图像的 MWE。
% \documentclass[ignorenonframetext]{beamer}
\documentclass{article}
\usepackage{beamerarticle}
\usepackage[skins]{tcolorbox}
\newtcolorbox{mybox}[2]{
lower separated=false,
colback=white,
colframe={#2},
fonttitle=\sffamily\bfseries,
% fontupper=\bfseries\sffamily,
colbacktitle={#2},
coltitle=white,
before upper=\par\noindent{},
enhanced,
attach boxed title to top left={yshift=-0.1in,xshift=0.15in},
boxed title style={boxrule=0pt,colframe=white,},
title={\color{white}{#1}}
}
\setbeamertemplate{block example begin}{%
\begin{mybox}{\insertblocktitle}{gray}\noindent%
}
\setbeamertemplate{block example end}{\end{mybox}}
\begin{document}
This is some text outside any frame.
\begin{mybox}{The title}{gray}\noindent
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ac feugiat
nisi. Donec vitae pretium magna. Sed eget mi felis. Morbi luctus quis nulla
nec eleifend. Suspendisse et justo ex. Ut at quam a dui auctor tempor.
Proin elementum lacus turpis. Praesent blandit sollicitudin ipsum, a
eleifend metus gravida non.
\end{mybox}
\begin{frame}{Frame}
\begin{exampleblock}{Block}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ac feugiat
nisi. Donec vitae pretium magna. Sed eget mi felis. Morbi luctus quis nulla
nec eleifend. Suspendisse et justo ex. Ut at quam a dui auctor tempor.
Proin elementum lacus turpis. Praesent blandit sollicitudin ipsum, a
eleifend metus gravida non.
\end{exampleblock}
\end{frame}
\end{document}
答案1
您想要删除\noindent
:
\documentclass[ignorenonframetext]{beamer}
%\documentclass{article}
%\usepackage{beamerarticle}
\usepackage[skins]{tcolorbox}
\newtcolorbox{mybox}[2]{
lower separated=false,
colback=white,
colframe={#2},
fonttitle=\sffamily\bfseries,
% fontupper=\bfseries\sffamily,
colbacktitle={#2},
coltitle=white,
before upper=\par\noindent{},
enhanced,
attach boxed title to top left={yshift=-0.1in,xshift=0.15in},
boxed title style={boxrule=0pt,colframe=white,},
title={\color{white}{#1}}
}
\setbeamertemplate{block example begin}{%
\begin{mybox}{\insertblocktitle}{gray}%
}
\setbeamertemplate{block example end}{\end{mybox}}
\begin{document}
This is some text outside any frame.
\begin{mybox}{The title}{gray}\noindent
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ac feugiat
nisi. Donec vitae pretium magna. Sed eget mi felis. Morbi luctus quis nulla
nec eleifend. Suspendisse et justo ex. Ut at quam a dui auctor tempor.
Proin elementum lacus turpis. Praesent blandit sollicitudin ipsum, a
eleifend metus gravida non.
\end{mybox}
\begin{frame}{Frame}
\begin{exampleblock}{Block}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ac feugiat
nisi. Donec vitae pretium magna. Sed eget mi felis. Morbi luctus quis nulla
nec eleifend. Suspendisse et justo ex. Ut at quam a dui auctor tempor.
Proin elementum lacus turpis. Praesent blandit sollicitudin ipsum, a
eleifend metus gravida non.
\end{exampleblock}
\end{frame}
\end{document}