2 列のブロックの位置合わせに問題がありますか?

2 列のブロックの位置合わせに問題がありますか?

ビーマー フレームの次のコードを考えてみます。

\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}

次の結果が生成されます。 図

問題は、右側のブロックがテキスト全体の幅に正しく揃えられていないことです。

正しく位置合わせするにはどうすればいいですか?

編集:

次のパッケージをロードします。

\usepackage{marvosym} %
\usepackage{ragged2e} % define justifying
\usepackage{hyperref} %
\usepackage{transparent} %

答え1

@barbarabeeton がコメントで指摘しているように、\strut--のようなもの\mathstrutを左側のexampleblock環境、つまり、 という単語を含む環境に挿入する必要があることがわかりました。 という単語Leftにはディセンダーのある文字は含まれませんが、 -- には含まれますRight

LaTeX カーネルでは、は幅がゼロで、高さが 、深さが\strutの目に見えない垂直線として定義されています。したがって、その合計の高さは に等しくなります。対照的に、 aの合計の高さは文字の高さと同じです。したがって、 A はa よりもわずかに高くなります。どちらにしても、 と の両方が左側のブロックに十分な深さを提供します。0.7\baselineskip0.3\baselineskip\baselineskip\mathstrut)\strut\mathstrut\strut\mathstrut

一般的に、支柱を設置する必要があるかもしれない両方左側と右側の exampleblock 環境、特に 1 つのブロックにアセンダはあるがディセンダがない単語 (例: left、 ) が含まれ、もう 1 つのブロックにディセンダはあるがアセンダがない単語 (例: 、 )blackが含まれる場合。greenuvwxyz

ここに画像の説明を入力してください

\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} 

答え2

ここに画像の説明を入力してください

\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}

関連情報