我想将一些代码放在标签为带圆圈字母的标签内enumerate
。我正在关注这个问题获取圆圈内的字母标签,但我遇到了间距问题:
\documentclass{article}
\usepackage{tikz}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{courier}
\lstset{basicstyle=\footnotesize\tt}
\begin{document}
\newcommand*\circlabel[1]{%
\begin{tikzpicture}[baseline=(C.base)]
\node[draw,circle,inner sep=1pt,minimum size=4ex](C) {#1};
\end{tikzpicture}}
\begin{enumerate}[label=\protect\circlabel{$\Alph*$}]
\item
\begin{lstlisting}[language=Java,gobble=12]
int someCode = 0;
int onMultipleLines = 1;
int likeThis = 2;
\end{lstlisting}
\end{enumerate}
\end{document}
如何消除第一行和第二行代码之间的空格?
答案1
一种选择是使用overlay
的选项tikzpicure
,这样它就不会占用空间并进行调整labelsep
:
\documentclass{article}
\usepackage{tikz}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{courier}
\lstset{basicstyle=\footnotesize\tt}
\begin{document}
\newcommand*\circlabel[1]{%
\begin{tikzpicture}[baseline=(C.base),overlay]
\node[draw,circle,inner sep=1pt,minimum size=4ex](C) {#1};
\end{tikzpicture}}
\begin{enumerate}[label=\protect\circlabel{$\Alph*$},labelsep=15pt]
\item
\begin{lstlisting}[language=Java,gobble=12]
int someCode = 0;
int onMultipleLines = 1;
int likeThis = 2;
\end{lstlisting}
\end{enumerate}
\end{document}