下面的代码确实产生了明显过高的列。在其他环境中也可以看到同样的效果(中心,...)。
我怎样才能使用 p 列并同时获得正确的高度?
代码:
\documentclass{scrreprt}
\usepackage{listings}
\begin{document}
\begin{tabular}{|p{1cm}|p{8cm}|}
\hline
A &%
\begin{lstlisting}
[1.67007,1.99831e-06,0.000413824]
\end{lstlisting} \\
\hline
\end{tabular}
\begin{tabular}{|p{1cm}|l|}
\hline
A &%
\begin{lstlisting}
[1.67007,1.99831e-06,0.000413824]
\end{lstlisting} \\
\hline
\end{tabular}
\end{document}
答案1
解决方法是分别指定aboveskip
和belowskip
减去文档点大小和减去基线跳过:
\documentclass{scrreprt}
\usepackage{listings}
\begin{document}
\begin{tabular}{|p{1cm}|p{8cm}|}
\hline
A &%
\begin{lstlisting}[aboveskip=-10pt,belowskip=-\baselineskip]
[1.67007,1.99831e-06,0.000413824]
\end{lstlisting} \\
\hline
\end{tabular}
\begin{tabular}{|p{1cm}|l|}
\hline
A &%
\begin{lstlisting}
[1.67007,1.99831e-06,0.000413824]
\end{lstlisting} \\
\hline
\end{tabular}
\end{document}