在一张幻灯片中,两个区块使用列对齐,但左右两侧的间距不相等,即,如本例所示,两列不在页面上居中。我尝试将列括进去,\begin{centering}
但似乎不起作用。如何使两列居中?
% Preview source code
%% LyX 2.0.3 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{beamer}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
% this default might be overridden by plain title style
\newcommand\makebeamertitle{\frame{\maketitle}}%
\AtBeginDocument{
\let\origtableofcontents=\tableofcontents
\def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
\def\gobbletableofcontents#1{\origtableofcontents}
}
\long\def\lyxframe#1{\@lyxframe#1\@lyxframestop}%
\def\@lyxframe{\@ifnextchar<{\@@lyxframe}{\@@lyxframe<*>}}%
\def\@@lyxframe<#1>{\@ifnextchar[{\@@@lyxframe<#1>}{\@@@lyxframe<#1>[]}}
\def\@@@lyxframe<#1>[{\@ifnextchar<{\@@@@@lyxframe<#1>[}{\@@@@lyxframe<#1>[<*>][}}
\def\@@@@@lyxframe<#1>[#2]{\@ifnextchar[{\@@@@lyxframe<#1>[#2]}{\@@@@lyxframe<#1>[#2][]}}
\long\def\@@@@lyxframe<#1>[#2][#3]#4\@lyxframestop#5\lyxframeend{%
\frame<#1>[#2][#3]{\frametitle{#4}#5}}
\newenvironment{topcolumns}{\begin{columns}[t]}{\end{columns}}
\def\lyxframeend{} % In case there is a superfluous frame end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\setbeamertemplate{blocks}[shadow=false]
\beamertemplatenavigationsymbolsempty
\usecolortheme{rose}
\useinnertheme{circles}
\makeatother
\usepackage{babel}
\begin{document}
\lyxframeend{}\lyxframe{My slide}
\begin{center}
\begin{topcolumns}%{}
\noindent
\column{0.5\textwidth}
\begin{exampleblock}
{A short list\inputencoding{latin1}{\phantom{g}}\inputencoding{latin9}}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{exampleblock}
\column{0.5\textwidth}
\begin{exampleblock}
{A long list}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\item Item 4
\item Item 5
\item Item 6
\end{itemize}
\end{exampleblock}
\end{topcolumns}%{}
\end{center}
\lyxframeend{}
\end{document}
答案1
我认为这是主题的问题。在回答中,我将演示默认主题与其他主题相比会有不同的行为。
例如:
\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usetheme{CambridgeUS}
\setbeamertemplate{blocks}[shadow=false]
\beamertemplatenavigationsymbolsempty
\usecolortheme{rose}
\useinnertheme{circles}
\begin{document}
\begin{frame}{My slide}
\begin{columns}[T]
\begin{column}{0.45\textwidth}
\begin{exampleblock}
{A short list}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{exampleblock}
\end{column}
\begin{column}{0.45\textwidth}
\begin{exampleblock}
{A long list}
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\item Item 4
\item Item 5
\item Item 6
\end{itemize}
\end{exampleblock}
\end{column}
\end{columns}
\end{frame}
\end{document}
导致:
并且没有水平对齐,但选择CambridgeUS
主题时
\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usetheme{CambridgeUS}
....
结果是一个以块为中心的框架(第一个块之前的左侧空间与第二个块之后的右侧空间相同):
答案2
嗯,我想你只需要告诉列到中心列,就像 beamer 文档中所述的那样。
而不是\begin{topcolumns}
使用:
\begin{columns}[onlytextwidth]
...
\end{columns}
并指定较小的列宽,例如\columns{0.45\textwidth}
答案3
在default
模板中,块基于beamercolorbox
环境,而rounded
模板根据环境重新定义所有块beamerboxesrounded
。这两个框环境之间的一个区别是它们的宽度定义方式。如果beamercolorbox
框的宽度等于其可视宽度。另一方面,如果宽度等于beamerboxesrounded
框内的文本宽度,即框边框和文本之间的填充/边距不会添加到总宽度中:
\documentclass[english]{beamer}
\usepackage[T1]{fontenc}
\usepackage{babel}
\setbeamertemplate{blocks}[shadow=false]
\beamertemplatenavigationsymbolsempty
\usecolortheme{rose}
\useinnertheme{circles}
\newlength{\mylen}
\begin{document}
\begin{frame}
\begin{columns}[t]
\column{0.25\textwidth}
\column{0.5\textwidth}
\settowidth{\mylen}{%
\begin{beamercolorbox}[colsep*=.75ex]{block title example}
\end{beamercolorbox}}
\begin{beamercolorbox}[colsep*=.75ex]{block title example}
beamercolorbox
\end{beamercolorbox}{\parskip0pt\par\nointerlineskip\vskip-0.5pt}%
\begin{beamercolorbox}[colsep*=.75ex]{block body example}
width = \the\mylen
\end{beamercolorbox}
\rule[0.3\baselineskip]{\textwidth}{2pt}
\settowidth{\mylen}{%
\begin{beamerboxesrounded}[upper=block title,lower=block body]{beamerboxesrounded}
\end{beamerboxesrounded}}
\begin{beamerboxesrounded}[upper=block title example,%
lower=block body example]{beamerboxesrounded}
width = \the\mylen
\end{beamerboxesrounded}
\column{0.25\textwidth}
\end{columns}
\end{frame}
\end{document}
在上面的例子中,黑色规则的宽度是列的文本宽度。两个示例块的视觉宽度都比文本宽度宽,但只有在beamercolorbox
实际宽度相同的情况下才如此。这正是导致错位的原因。
由于在许多地方使用,我不建议更改该环境的行为。但是,您可以更改(以及您使用的其他此类块)beamercolorbox
的定义:exampleblock
\documentclass[english]{beamer}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[width=14cm,height=11cm, landscape, frame, center]{crop}
\setbeamertemplate{blocks}[shadow=false]
\beamertemplatenavigationsymbolsempty
\usecolortheme{rose}
\useinnertheme{circles}
% redefinition of 'example block'
\newsavebox{\squaredblocktext}
\defbeamertemplate*{block example begin}{squared}
{
\par\vskip\medskipamount%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex]{block title example}
\usebeamerfont*{block title example}\insertblocktitle%
\end{beamercolorbox}}%
\begin{lrbox}{\squaredblocktext}\begin{minipage}[t]{\textwidth}%
\ifbeamercolorempty[bg]{block body example}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\defbeamertemplate*{block example end}{squared}
{
\end{minipage}\end{lrbox}%
{\parskip0pt\par}%
\ifbeamercolorempty[bg]{block title example}
{}
{\ifbeamercolorempty[bg]{block body example}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body example}%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex,vmode]{block body example}%
\usebox{\squaredblocktext}
\end{beamercolorbox}%
}\vskip\smallskipamount%
}
% end redefinition of 'example block'
\begin{document}
\begin{frame}{Alignment of squared example blocks}
\begin{columns}[t]
\column{0.5\textwidth}
\begin{exampleblock}{A very short list}
\begin{itemize}
\item Item 1
\end{itemize}
\end{exampleblock}
\column{0.5\textwidth}
\begin{exampleblock}{A longer list}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\end{exampleblock}
\end{columns}
\end{frame}
\end{document}
请注意,加载该crop
包只是为了在页面周围绘制边框(以便更容易看到对齐)。
如果您正在使用其他块,则也需要进行这样的重新定义。
我认为,更好的解决方案是定义一个beamerboxessquared
类似于beamerboxesrounded
作为默认块的基础。不幸的是,我对 PGF 的了解还不够。也许其他人可以加入进来?