题
如何将文本集中在乳胶中的列表中?
或不使用清单的另一种方式。 (需要一个带有单层字体的盒子)
解决方案
给出的答案 Tex.Stackexchange 是:
\documentclass{article}
\usepackage{listings}
\renewcommand{\figurename}{Listing}
% replace figurename with the text that should preceed the caption
\begin{document}
\begin{figure}[thp] % the figure provides the caption
\centering % which should be centered
\caption{Ausgabe des C-Programms}
\begin{tabular}{c} % the tabular makes the listing as small as possible and centers it
\begin{lstlisting}[label={gtt_c_ausgabe}]
printf("Your code goes here.\n");
\end{lstlisting}
\end{tabular}
\end{figure}
\end{document}
...这仍然让我想知道:
使用代码框架,例如使用 \lstset{frame=single,frameround=tttt}
, ,将框架向右走。如何避免这种情况?
什么是 renewcommand
有点吗?
其他提示
我没有列出的清单包的答案,但是您可以尝试以下操作:
\framebox[.9\linewidth]{\parbox{.85\linewidth}{\tt Hello World\\Second line}}
这会产生一个具有线宽度90%的盒子,宽度为85%的线条宽度。
如果您想要它的中心 \centering
在......面前 \tt
命令:
\framebox[.9\linewidth]{\parbox{.85\linewidth}{\centering \tt Hello World\\Second line}}
如果您喜欢没有框架的盒子,只需更改 \framebox
进入 \makebox
(并保持论点的立场)。
不隶属于 StackOverflow