出于某种原因,尽管设置了listings
该选项,但包在下面的最小工作示例中仍然断行。breaklines=false
\documentclass{article}
\usepackage{listings}
\lstset{
breaklines=false,
basicstyle=\ttfamily
}
\begin{document}
\begin{lstlisting}
Number of obs = 2239
Wald chi2(6) = .
Log pseudolikelihood = -1512.9798 Prob > chi2 = .
(Std. Err. adjusted for 115 clusters in id)
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
crra |
test1 | .9284791 .1856117 5.00 0.000 .5646869 1.292271
_cons | 1.203079 .7054548 1.71 0.088 -.1795867 2.585745
-------------+----------------------------------------------------------------
gamma |
_cons | 1.251066 .4030218 3.10 0.002 .4611582 2.040975
-------------+----------------------------------------------------------------
noise |
female | 6.967949 29.98527 0.23 0.816 -51.80211 65.738
_cons | 46.31619 . . . . .
------------------------------------------------------------------------------
\end{lstlisting}
\end{document}
截屏:
答案1
添加columns=fullflexible
,当使用等宽字体时效果最佳。您还需要keepspaces
。
\documentclass{article}
\usepackage{listings}
\lstset{
basicstyle=\ttfamily,
columns=fullflexible,
keepspaces,
}
\begin{document}
\begin{lstlisting}
Number of obs = 2239
Wald chi2(6) = .
Log pseudolikelihood = -1512.9798 Prob > chi2 = .
(Std. Err. adjusted for 115 clusters in id)
------------------------------------------------------------------------------
| Robust
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
crra |
test1 | .9284791 .1856117 5.00 0.000 .5646869 1.292271
_cons | 1.203079 .7054548 1.71 0.088 -.1795867 2.585745
-------------+----------------------------------------------------------------
gamma |
_cons | 1.251066 .4030218 3.10 0.002 .4611582 2.040975
-------------+----------------------------------------------------------------
noise |
female | 6.967949 29.98527 0.23 0.816 -51.80211 65.738
_cons | 46.31619 . . . . .
------------------------------------------------------------------------------
\end{lstlisting}
\end{document}
然而你应该将它与以下实现进行比较:
\documentclass{article}
\usepackage{booktabs,siunitx}
\begin{document}
\begin{table}
\caption{A better one}
\medskip
\addtolength{\tabcolsep}{-2pt}
\begin{tabular}{
@{}
r
S[table-format=2.7]
S[table-format=2.7]
S[table-format=1.2]
S[table-format=1.3]
S[table-format=-2.7]
S[table-format=-2.6]
@{}
}
\toprule
\multicolumn{7}{@{}c@{}}{%
Log pseudolikelihood = \num{-1512.9798}\hfill
\begin{tabular}[b]{@{}l@{${}={}$}S[table-format=4.0]@{}}
Number of obs & 2239 \\
Wald $\chi^2(6)$ & {--} \\
Prob $> \chi^2$ & {--} \\
\end{tabular}%
}
\\[1ex]
\multicolumn{7}{@{}r@{}}{(Std.\ Err.\ adjusted for 115 clusters in id)}
\\
\midrule
& {Coef.}
& {\begin{tabular}{@{}c@{}}Robust\\Std.\ Err.\end{tabular}}
& {$z$}
& {$P>|z|$}
& \multicolumn{2}{c@{}}{95\% Conf.\ Interval}
\\
\midrule
\multicolumn{1}{@{}l}{crra}\\
test1 & .9284791 & .1856117 & 5.00 & 0.000 & .5646869 & 1.292271 \\
\_cons & 1.203079 & .7054548 & 1.71 & 0.088 & -.1795867 & 2.585745 \\
\midrule
\multicolumn{1}{@{}l}{gamma}\\
\_cons & 1.251066 & .4030218 & 3.10 & 0.002 & .4611582 & 2.040975 \\
\midrule
\multicolumn{1}{@{}l}{noise}\\
female & 6.967949 & 29.98527 & 0.23 & 0.816 & -51.80211 & 65.738 \\
\_cons & 46.31619 & {--} & {--} & {--} & {--} & {--} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}