質問

LaTexのリスト内にテキストを集中させるにはどうすればよいですか?

または、リストを使用しない別の方法。 (Monospaceフォント付きのボックスが必要です)

役に立ちましたか?

解決

で与えられた答え 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 (そして、彼らが立っている間、議論を維持します)。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top