我是 Latex 的新手,正在尝试使用列表。
我的包裹正在跟踪,
\usepackage[utf8]{inputenc}
\usepackage{tabularx,ragged2e,booktabs,caption,multirow}
\usepackage{amsmath,amssymb}
\usepackage{etoolbox}
\usepackage[T1]{fontenc}
\usepackage{inconsolata}
\usepackage{color}
\definecolor{pblue}{rgb}{0.13,0.13,1}
\definecolor{pgreen}{rgb}{0,0.5,0}
\definecolor{pred}{rgb}{0.9,0,0}
\definecolor{pgrey}{rgb}{0.46,0.45,0.48}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\usepackage[newfloat]{minted}
\usepackage{listings}
\lstset{language=Java,
showspaces=false,
showtabs=false,
breaklines=true,
showstringspaces=false,
breakatwhitespace=true,
commentstyle=\color{pgreen},
keywordstyle=\color{pblue},
stringstyle=\color{pred},
basicstyle=\ttfamily,
moredelim=[il][\textcolor{pgrey}]{$$},
moredelim=[is][\textcolor{pgrey}]{\%\%}{\%\%}
}
\lstset{
language=XML,
basicstyle=\ttfamily,
columns=fullflexible,
showstringspaces=false,
commentstyle=\color{gray}\upshape
}
\lstdefinelanguage{XML}
{
morestring=[b]",
morestring=[s]{>}{<},
morecomment=[s]{<?}{?>},
stringstyle=\color{black},
identifierstyle=\color{darkblue},
keywordstyle=\color{cyan},
morekeywords={xmlns,version,type}% list your attributes here
}
我的 XML 代码是
\begin{figure}
\begin{lstlisting}[language=XML]
<?xml version="1.0" encoding="UTF-8"?>
<!-- when there are too many cars -->
<policy id="1" priority="10">
</policy>
\end{lstlisting}
\caption{Example code policy}
\label{lst:policyex}
\end{figure}
为了将其添加到 listoffigures 中,我用 figure 标签将其包围。
问题是,我的 XML 代码单独位于一个页面中。
我想用段落而不是分页符来包装我的 XML 代码。
我尝试使用 minipage、float,但它也不起作用。
我应该怎么办??
答案1
\begin{figure}[htb]
\centering
\begin{lstlisting}[language=XML]
<?xml version="1.0" encoding="UTF-8"?>
<!-- when there are too many cars -->
<policy id="1" priority="10">
</policy>
\end{lstlisting}
\caption{Example code policy}
\label{lst:policyex}
\end{figure}
我刚刚htb
在图形标签中添加了选项,然后\centering
......