我有以下 LaTeX 代码:
\documentclass[11pt]{book}
\usepackage[default]{opensans}
\usepackage{alltt}
\usepackage[listings]{tcolorbox}
\usepackage{xcolor}
\newenvironment{generalSrcCode}
{\vspace{5pt}
\begin{tcolorbox}[
colback=lightgray,
coltext=black,
boxrule=0pt,
arc=5pt,
before skip=5pt,
after skip=5pt,
left=5pt,
right=5pt,
top=5pt,
bottom=5pt,
boxsep=0pt,
valign=center,
baseline = 0pt
]\begin{alltt}\color{black}\ignorespaces}
{\end{alltt}\end{tcolorbox}
\vspace{5pt}
}
\begin{document}
\noindent
Run the following commands in a terminal:
\begin{generalSrcCode}
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
\end{generalSrcCode}
\noindent
Once you have run the above-mentioned commands,
\end{document}
如您所见,tcolorbox 中第二个命令的末尾有一个空行。我想删除它并将内容垂直居中在框中。这可能吗?
提前致谢
由于您无论如何都要在代码周围使用
tcolorbox
,因此我会直接使用tcblisting
: