我想定义一个块环境,如链接中的图所示
我使用代码制作了这个块
\begin{block}{My title\\ \vspace{-1.25em} \line(1,0){312}}\vspace{-0.7em}
teste
\end{block}
有人知道怎么做吗?顺便问一下,如何使用 XeLaTeX 更改标题字体?
答案1
在内部,beamer
使用阴影bmb@transition
在标题和块的正文部分之间添加一些颜色。您可以重新定义此阴影以产生纯色:
\documentclass{beamer}
\setbeamertemplate{blocks}[rounded][shadow]
\setbeamercolor{block title}{fg=blue!70!black,bg=white}
\setbeamercolor{block body}{bg=white}
\makeatletter
\pgfdeclareverticalshading{bmb@transition}{200cm}{%
color(0pt)=(blue!70!black); color(2pt)=(blue!70!black)}
\makeatother
\begin{document}
\begin{frame}
\begin{block}{My Title}
Test text.
\end{block}
\end{frame}
\end{document}
在上面的代码中,线宽将等于块宽度。如果希望规则宽度等于块内文本的宽度,则需要采用不同的方法;在这种情况下,tcolorbox
包可以与其皮肤一起使用beamer
,以产生与块具有相同规格的块beamer
,然后可以轻松添加具有所需规格的规则。
一个小例子,比较两种方法:一个标准块(规则宽度=块宽度)和一个在(规则宽度=文本宽度)beamer
的帮助下生成的 Bblock :tcolorbox
\documentclass{beamer}
\usepackage[most]{tcolorbox}
\setbeamertemplate{blocks}[rounded][shadow]
\usetikzlibrary{shadings,shadows}
\setbeamercolor{block title}{fg=blue!70!black,bg=white}
\setbeamercolor{block body}{bg=white}
\makeatletter
\pgfdeclareverticalshading{bmb@transition}{200cm}{%
color(0pt)=(blue!70!black); color(2pt)=(blue!70!black)}
\makeatother
\newtcolorbox{Bblock}[2][]{
beamer,
equal height group=beamer,
colback=white,
colframe=white,
coltitle=blue!70!black,
fonttitle=\normalfont\large,
oversize,
overlay={
\draw[blue!70!black,ultra thick]
([xshift=6pt,yshift=-0.5\pgflinewidth]title.south west) --
([xshift=-6pt,yshift=-0.5\pgflinewidth]title.south east);},
left=1mm,
right=1mm,
top=1mm,
bottom=1mm,
middle=1mm,
fuzzy shadow={0.6ex}{-0.6ex}{1pt}{0.5pt}{black!80!white},
#1,title=#2}
\makeatletter
\tikzset{beamer@color/.style={top color=white,bottom color=white}}
\makeatother
\newcommand\Text{%just for the example
Quisque ullamcorper placerat ipsum. Cras nibh. Morbi vel justo
vitae lacus tincidunt ultrices. Lorem ipsum dolor sit amet, con-
sectetuer adipiscing elit. In hac habitasse platea dictumst. Integer
tempus convallis augue. Etiam facilisis. Nunc elementum fermen-
tum wisi.}
\begin{document}
\begin{frame}
\begin{block}{My Title}
\Text
\end{block}
\begin{Bblock}{My Title}
\Text
\end{Bblock}
\end{frame}
\end{document}