我正在尝试将其放置lstlisting
在桌子上,但是我得到了一些我不想要的额外空间并且不知道它来自哪里:
\documentclass[11pt,twoside,openright]{memoir}
\usepackage{tcolorbox}
\usepackage[scaled]{beramono}
\renewcommand*\familydefault{\ttdefault}
\usepackage[T1]{fontenc}
\usepackage{listings}
\begin{document}
\lstset{ language=bash,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
frame=single }
\begin{tcolorbox}[title=foo2bar]
\small
\begin{tabular}{rp{0.72\linewidth}}
Foo: & foo2bar \\
Command: & \begin{lstlisting}
sed 's/foo/bar/g' ../fooer.foo.txt > fooer.foo.txt.foo2bar.bar.txt
\end{lstlisting} \\
Bar: & \\
\end{tabular}
\end{tcolorbox}
\end{document}
下图中用青色标记:
它们从哪里来?更重要的是,我该如何摆脱它们?:)
答案1
我也会使用 tcolorbox 来制作列表:它有更多更强大的键来调整外观。例如
\documentclass[11pt,twoside,openright]{memoir}
\usepackage[most]{tcolorbox}
\usepackage[scaled]{beramono}
\renewcommand*\familydefault{\ttdefault}
\usepackage[T1]{fontenc}
\usepackage{listings}
\begin{document}
\lstset{ language=bash,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
%frame=single
}
\begin{tcolorbox}[title=foo2bar]
\small
\begin{tabular}{rp{0.72\linewidth}}
Foo: & foo2bar \\
Command: &
\begin{tcblisting}{sharp corners, listing only, baseline=\dimexpr\csname tcb@height\endcsname-\normalbaselineskip\relax,after={}}
sed 's/foo/bar/g' ../fooer.foo.txt > fooer.foo.txt.foo2bar.bar.txt
\end{tcblisting}
\\
Bar: & \\
\end{tabular}
\end{tcolorbox}
\end{document}