我目前正尝试添加标题、中心和引用铸造的文本,但似乎无法这样做。
这是我迄今为止尝试过的……
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{float}
\usepackage{minted}
\begin{document}
D is the number of deletion. A deletion is when a
word in the reference sentenced is not occuring in
the hypothesised sentence as seen in example
\ref{verb:deletion}\\
\begin{centering}
\begin{listing}[H]
\begin{minted}{bash}
referenced: Today is monday.
hypothesised: Today monday.
\end{minted}
\caption{Example of the deletion metric of the WER, in which a word is deleted in the hypothesized compared to the referenced. }
\label{verb:deletion}
\end{listing}
\end{centering}
\end{document}
这给了我这个
我的问题是它没有居中,标题中的列表可以更改为其他内容吗?例如?...或者是否有任何自然的方式来为铸造盒添加标题?
答案1
listings
您可以通过重新定义来更改环境的标题名称\listingscaption
。环境
minted
始终占据整个可用文本宽度。您可以在其周围绘制一个框时看到这一点(通过将选项添加frame=single
到 minted 环境)。因此它是正确居中,但因为它占据了整个文本宽度,所以你看不到它。我不知道如何
minted
动态地创建环境更窄,但作为一种解决方法,您可以尝试在环境的左侧和右侧添加边距minted
(通过添加选项xleftmargin=...
,xrightmargin=...
)。- 无论如何,这是描述
minted
环境的自然方式。
以下是一个例子:
\documentclass{article}
\usepackage{minted}
\renewcommand{\listingscaption}{Example}
\begin{document}
D is the number of deletion. A deletion is when a word in the reference sentenced is not occuring in the hypothesised sentence as seen in example \ref{verb:deletion}.
\begin{listing}[H]\centering
\begin{minted}[autogobble,xleftmargin=0.2\textwidth,xrightmargin=0.2\textwidth,frame=single]{bash}
referenced: Today is monday.
hypothesised: Today monday.
\end{minted}
\caption{Example of the deletion metric of the WER, in which a word is deleted in the hypothesized compared to the referenced. }
\label{verb:deletion}
\end{listing}
\end{document}
更多说明:
autogobble
动态删除每行公共的前导空格。- 我
frame=single
在这里仅用于说明 - 您可以轻松将其删除。 - 不
centering
应该位于浮动环境周围listing
,而应该位于其内部(尽管在这种情况下没有效果)。