
Considere el siguiente código de un marco de proyector:
\begin{frame}{Test}
\begin{block}{Single column}
\justifying
This is a block.
\end{block}
\begin{columns}[onlytextwidth]
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Left}
\justifying
This is the first column.
\end{exampleblock}
\end{column}
\begin{column}[right]{0.45\textwidth}
\begin{exampleblock}{Right}
\justifying
This is the second column.
\end{exampleblock}
\end{column}
\end{columns}
\end{frame}
Produce el siguiente resultado:
El problema es que el bloque derecho no está alineado correctamente con todo el ancho del texto.
¿Cómo alinearlo correctamente?
EDITAR:
Cargo los siguientes paquetes:
\usepackage{marvosym} %
\usepackage{ragged2e} % define justifying
\usepackage{hyperref} %
\usepackage{transparent} %
Respuesta1
Como ha observado @barbarabeeton en un comentario, resulta necesario insertar algo como \strut
-- \mathstrut
también servirá -- en el entorno de la izquierda exampleblock
, es decir, el que contiene la palabra Left
, que no contiene letras con descendentes - mientras Right
que sí.
En el kernel de LaTeX, \strut
se define como una regla vertical de ancho cero y, por lo tanto, invisible con altura 0.7\baselineskip
y profundidad 0.3\baselineskip
; por tanto, su altura total es igual a \baselineskip
. Por el contrario, la \mathstrut
altura total de a es la del )
personaje. Por tanto, A \strut
es ligeramente más alto que a \mathstrut
. De cualquier manera, ambos \strut
proporcionan \mathstrut
suficiente profundidad al bloque de la izquierda.
En general, puede ser necesario proporcionar puntales enamboslos entornos de bloques de ejemplo de la izquierda y de la derecha, especialmente si un bloque contiene palabras con ascendentes pero no descendentes (por ejemplo, left
, black
) y el otro contiene palabras con descendientes pero sin ascendentes (por ejemplo, green
, uvwxyz
).
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{marvosym} %
\usepackage{ragged2e} % define justifying
\usepackage{transparent} %
\usepackage{hyperref} %
\begin{document}
\begin{frame}{Test}
\begin{block}{Single column}
\justifying
This is a block.
\end{block}
\begin{columns}[onlytextwidth]
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Left\strut}
\justifying
This is the first column.
\end{exampleblock}
\end{column}
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Right}
\justifying
This is the second column.
\end{exampleblock}
\end{column}
\end{columns}
\end{frame}
\end{document}
Respuesta2
\documentclass{beamer}
\usetheme{Boadilla}
\newsavebox{\squaredblocktext}
\setbeamertemplate{block begin}{
\par\vskip\medskipamount%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex]{block title}
\usebeamerfont*{block title}\insertblocktitle%
\end{beamercolorbox}}%
\begin{lrbox}{\squaredblocktext}%
\begin{minipage}[t]{\textwidth}%
\ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\setbeamertemplate{block end}{
\end{minipage}%
\end{lrbox}%
{\parskip0pt\par}%
\ifbeamercolorempty[bg]{block title}{}
{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body}%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
\usebox{\squaredblocktext}
\end{beamercolorbox}%
}\vskip\smallskipamount%
}
\setbeamertemplate{block example begin}{
\par\vskip\medskipamount%
\makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
\begin{beamercolorbox}[colsep*=.75ex]{block title example}
\usebeamerfont*{block titleexample}\insertblocktitle%
\end{beamercolorbox}}%
\begin{lrbox}{\squaredblocktext}%
\begin{minipage}[t]{\textwidth}%
\ifbeamercolorempty[bg]{block body example}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\setbeamertemplate{block example end}{
\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%
}
\begin{document}
\begin{frame}{Test}
\begin{block}{Single column}
This is a block.
\end{block}
\begin{columns}[onlytextwidth]
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Left}
This is the first column.
\end{exampleblock}
\end{column}
\begin{column}{0.45\textwidth}
\begin{exampleblock}{Right}
This is the second column.
\end{exampleblock}
\end{column}
\end{columns}
\end{frame}
\end{document}