我尝试在列环境中使用 \newline,但似乎不起作用。这是最低限度的工作代码。
\documentclass{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\usefonttheme{serif}
\setbeamertemplate{frame numbering}[fraction]
\usepackage{tcolorbox}
\usepackage{xcolor}
\begin{document}
\begin{frame}
\frametitle{test}
\begin{columns}
\begin{column}{0.46\textwidth}
\begin{itemize}
\item bloop
\item foo
\end{itemize}
\end{column}
\begin{column}{0.65\textwidth}
\begin{itemize}
\item test
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black,hbox]
\scriptsize\texttt{line1}
\scriptsize\texttt{line2}
\end{tcolorbox}
\end{itemize}
\end{column}
\end{columns}
\end{frame}
\end{document}
我正在尝试将“line1”和“line2”放在两条不同的行中。您能否给我一些提示,告诉我如何实现这一点?提前谢谢。
答案1
以下是两种不同的可能性:
\documentclass{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\usefonttheme{serif}
\setbeamertemplate{frame numbering}[fraction]
\usepackage{tcolorbox}
\usepackage{array}
\usepackage{xcolor}
\begin{document}
\begin{frame}
\frametitle{empty line between "line 1" and "line 2" and without hbox}
\begin{columns}
\begin{column}{0.46\textwidth}
\begin{itemize}
\item bloop
\item foo
\end{itemize}
\end{column}
\begin{column}{0.65\textwidth}
\begin{itemize}
\item test
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
\scriptsize\ttfamily line1
line2
\end{tcolorbox}
\end{itemize}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\frametitle{with hbox and a tabular environment}
\begin{columns}
\begin{column}{0.46\textwidth}
\begin{itemize}
\item bloop
\item foo
\end{itemize}
\end{column}
\begin{column}{0.65\textwidth}
\begin{itemize}
\item test
\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black,hbox]
\begin{tabular}{@{}>{\scriptsize\ttfamily}l@{}}
line1 \\
line2
\end{tabular}
\end{tcolorbox}
\end{itemize}
\end{column}
\end{columns}
\end{frame}
\end{document}