我正在beamer
制作幻灯片。当我尝试在lstlist
项目列表中添加一些代码时,列表总是位于项目符号的下一行,如下图所示。
我的代码如下:
\documentclass[aspectratio=169]{beamer}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{listings}
\usepackage{lstautogobble}
\mode<presentation>
{
\usetheme{Warsaw}
\setbeamercovered{transparent}
}
\usecolortheme{crane}
\useoutertheme{split}
\usefonttheme[onlysmall]{structurebold}
\lstset{
basicstyle=\tiny \ttfamily,
frame=single,
}
\begin{document}
\section{listing in item}
\begin{frame}[t, fragile]{Listing in Item}
\begin{onlyenv}<+>
\begin{itemize}
\item
\begin{lstlisting}[autogobble]
How to align this with the bullet?
\end{lstlisting}
\end{itemize}
\end{onlyenv}
\end{frame}
\end{document}
是否可以将列表提升一行来与项目符号对齐?
答案1
快速解决方法:更改aboveskip
您的列表
\documentclass[aspectratio=169]{beamer}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{listings}
\usepackage{lstautogobble}
\mode<presentation>
{
\usetheme{Warsaw}
\setbeamercovered{transparent}
}
\usecolortheme{crane}
\useoutertheme{split}
\usefonttheme[onlysmall]{structurebold}
\lstset{
basicstyle=\tiny \ttfamily,
frame=single,
}
\begin{document}
\section{listing in item}
\begin{frame}[t, fragile]{Listing in Item}
\begin{onlyenv}<+>
\begin{itemize}
\item
\begin{lstlisting}[autogobble,aboveskip=-.8\baselineskip]
How to align this with the bullet?
\end{lstlisting}
\end{itemize}
\end{onlyenv}
\end{frame}
\end{document}