我有以下长列表。我使用了一个adjustbox
来适应线条并添加了[float=*]
到列表属性以将其放入两列。我正在使用这模板是基于两列的文章。问题如下图所示。如何防止这种情况发生?
平均能量损失
\documentclass{comjnl}
\usepackage{lipsum}
\usepackage{listings}
\usepackage{adjustbox}
\usepackage{url}
\usepackage{amsmath}
\usepackage{cuted}
\usepackage{hyperref}
\shortauthors{jd}
\begin{document}
\lipsum[50]
\lstset{
frame = single}
\begin{lstlisting}[caption={Regular expression used to extract links within HTML code of Web pages},label=Pattern,linewidth=12cm]
"https?://(?:www\\.)?[^\\n<>\"]+(?:\"[^<]*>([^<]*))?"
\end{lstlisting}
\lipsum[50]
\begin{strip}
\centering
\centering
\adjustbox{width=\textwidth, frame}{
\begin{lstlisting}[caption={A demonstration of a hierarchical XML file used in this experiment to evaluate our framework.},label=Layers,linewidth=20cm][float=*]
<?xml version="1.0" encoding="UTF-8"?>
<crawledURLs>
<URL adr="http://www.cs.tsinghua.edu.cn/publish/csen/index.html" id="0" info="">
<URL adr="http://www.tsinghua.edu.cn title=" id="1" info=""/>
-<URL adr="http://ss.cs.tsinghua.edu.cn" id="2" info="2017 Deep Learning Summer School">
<url ADR="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,300italic,400italic,700italic" ID="0" INFO=""/>
<url ADR="http://fontawesome.io/examples/ --" ID="1" INFO=""/>
<url ADR="http://www.cs.tsinghua.edu.cn/publish/csen/index.html" ID="2" INFO=""/>
<url ADR="http://www.tsinghua.edu.cn/publish/newthuen/newthuen_cnt/about-th/about-1.html" ID="3" INFO=""/>
</URL>
-<URL adr="http://thu-cmu.cs.tsinghua.edu.cn" id="3" info="Tsinghua-CMU Double Master Degree Progra...">
<url ADR="http://tv.tsinghua.edu.cn/folder1/folder20/2011/04/2011-04-215.html" ID="1" INFO=""/>
<url ADR="http://tv.tsinghua.edu.cn/folder1/folder20/2011/04/2011-04-215.html" ID="2" INFO="Tsinghua University Introduction"/>
<url ADR="http://www.tudou.com/programs/view/guyM0hdQNi4/?phd=99" ID="3" INFO=""/>
<url ADR="http://tv.tsinghua.edu.cn/folder1/folder20/2011/04/2011-04-215.html" ID="4" INFO="Campus Tour"/>
<url ADR="http://www.cs.tsinghua.edu.cn/" ID="5" INFO="DCST"/>
<url ADR="http://www.cmu.edu/index.shtml" ID="6" INFO="Carnegie Mellon University"/>
<url ADR="http://www.cs.tsinghua.edu.cn/" ID="7" INFO="Tsinghua CS Department"/>
<url ADR="http://www.cmu.edu/index.shtml" ID="8" INFO="CMU"/>
<url ADR="http://www.tsinghua.edu.cn/publish/th/index.html" ID="9" INFO="Tsinghua University"/>
</URL>
-<URL adr="http://ac.cs.tsinghua.edu.cn" id="4" info="Advanced Computing Master Program">
<url ADR="https://fonts.googleapis.com/icon?family=Material+Icons" ID="0" INFO=""/>
<url ADR="http://gradadmission.tsinghua.edu.cn" ID="1" INFO="Apply Now"/>
<url ADR="http://gradadmission.tsinghua.edu.cn" ID="2" INFO="Apply Now"/>
<url ADR="http://gradadmission.tsinghua.edu.cn" ID="3" INFO="Apply"/>
<url ADR="http://clem109.com" ID="4" INFO="clem109"/>
</URL>
<URL adr="http://www.csai.tsinghua.edu.cn/homepage.shtm" id="5" info="State Key Lab of Intelligence Techonoly ..."/>
<URL adr="http://media.cs.tsinghua.edu.cn/en/" id="6" info="Institute of HCI & Media Integration"/>
-<URL adr="http://soft.cs.tsinghua.edu.cn/English/index.html" id="7" info="Institute of Computer Software">
<url ADR="http://dbgroup.cs.tsinghua.edu.cn" ID="1" INFO="Data Engineering"/>
<url ADR="http://keg.cs.tsinghua.edu.cn" ID="2" INFO="Knowledge Engineering"/>
<url ADR="http://166.111.68.91" ID="3" INFO="Design Automation of Computer and VLSI Circuits"/>
<url ADR="http://vis.cs.tsinghua.edu.cn" ID="4" INFO="Visualization and Computer Graphics"/>
<url ADR="http://soft.cs.tsinghua.edu.cn/soft/" ID="5" INFO="Software Engineering and System Software"/>
<url ADR="http://dbgroup.cs.tsinghua.edu.cn" ID="6" INFO="Data Engineering"/>
<url ADR="http://keg.cs.tsinghua.edu.cn" ID="7" INFO="Knowledge Engineering"/>
<url ADR="http://166.111.68.91" ID="8" INFO="Design Automation of Computer and VLSI Circuit"/>
<url ADR="http://vis.cs.tsinghua.edu.cn" ID="9" INFO="Visualization Technology and Computer Graphics"/>
</URL>
<URL adr="http://network.cs.tsinghua.edu.cn" id="8" info="Institute of Computer Networks"/>
</URL>
</crawledURLs>
\end{lstlisting}
}
\end{strip}
\lipsum[50]
\lipsum[50]
\lipsum[50]
\lipsum[50]
\lipsum[50]
\end{document}
编辑
根据下面提供的答案,结果将是这样的。这就是使用adjustbox让列表在框中进行调整的全部意义~!
编辑2
当我用原始项目中的代码替换 Zarko 的答案时,adjustbox 似乎呈现如下效果:
编辑3 我检查了我的原始项目,并意识到问题是由于我在它之前有另一个列表而引起的。我编辑了 MWE 并将第一个列表添加到其中。编译新的 MWE 将产生以下快照:
答案1
不需要\adjustbox
,应该float=*
在 lstlisting 定义中。它是一个大浮点数,因此 LaTeX 将它推到自己的页面中。我使用 floatbarrier 只是为了显示它是一个浮动浮点数。
\documentclass{comjnl}
\usepackage{lipsum}
\usepackage{listings}
\usepackage{placeins}
%\usepackage{adjustbox}
\usepackage{url}
\usepackage{amsmath}
\usepackage{hyperref}
\shortauthors{jd}
\begin{document}
\lipsum
\lipsum[1-3]
\lstset{frame = single,
language=XML,
framexleftmargin=10pt,
basicstyle=\footnotesize\ttfamily,
breaklines=true}
\begin{lstlisting}[caption={A demonstration of a hierarchical XML file used in this experiment to evaluate our framework.},label=Layers,float=*]
% <?xml version="1.0" encoding="UTF-8"?>
<crawledURLs>
<URL adr="http://www.cs.tsinghua.edu.cn/publish/csen/index.html" id="0" info="">
<URL adr="http://www.tsinghua.edu.cn title=" id="1" info=""/>
-<URL adr="http://ss.cs.tsinghua.edu.cn" id="2" info="2017 Deep Learning Summer School">
<url ADR="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,300italic,400italic,700italic" ID="0" INFO=""/>
<url ADR="http://fontawesome.io/examples/ --" ID="1" INFO=""/>
<url ADR="http://www.cs.tsinghua.edu.cn/publish/csen/index.html" ID="2" INFO=""/>
<url ADR="http://www.tsinghua.edu.cn/publish/newthuen/newthuen_cnt/about-th/about-1.html" ID="3" INFO=""/>
</URL>
-<URL adr="http://thu-cmu.cs.tsinghua.edu.cn" id="3" info="Tsinghua-CMU Double Master Degree Progra...">
<url ADR="http://tv.tsinghua.edu.cn/folder1/folder20/2011/04/2011-04-215.html" ID="1" INFO=""/>
<url ADR="http://tv.tsinghua.edu.cn/folder1/folder20/2011/04/2011-04-215.html" ID="2" INFO="Tsinghua University Introduction"/>
<url ADR="http://www.tudou.com/programs/view/guyM0hdQNi4/?phd=99" ID="3" INFO=""/>
<url ADR="http://tv.tsinghua.edu.cn/folder1/folder20/2011/04/2011-04-215.html" ID="4" INFO="Campus Tour"/>
<url ADR="http://www.cs.tsinghua.edu.cn/" ID="5" INFO="DCST"/>
<url ADR="http://www.cmu.edu/index.shtml" ID="6" INFO="Carnegie Mellon University"/>
<url ADR="http://www.cs.tsinghua.edu.cn/" ID="7" INFO="Tsinghua CS Department"/>
<url ADR="http://www.cmu.edu/index.shtml" ID="8" INFO="CMU"/>
<url ADR="http://www.tsinghua.edu.cn/publish/th/index.html" ID="9" INFO="Tsinghua University"/>
</URL>
-<URL adr="http://ac.cs.tsinghua.edu.cn" id="4" info="Advanced Computing Master Program">
<url ADR="https://fonts.googleapis.com/icon?family=Material+Icons" ID="0" INFO=""/>
<url ADR="http://gradadmission.tsinghua.edu.cn" ID="1" INFO="Apply Now"/>
<url ADR="http://gradadmission.tsinghua.edu.cn" ID="2" INFO="Apply Now"/>
<url ADR="http://gradadmission.tsinghua.edu.cn" ID="3" INFO="Apply"/>
<url ADR="http://clem109.com" ID="4" INFO="clem109"/>
</URL>
<URL adr="http://www.csai.tsinghua.edu.cn/homepage.shtm" id="5" info="State Key Lab of Intelligence Techonoly ..."/>
<URL adr="http://media.cs.tsinghua.edu.cn/en/" id="6" info="Institute of HCI & Media Integration"/>
-<URL adr="http://soft.cs.tsinghua.edu.cn/English/index.html" id="7" info="Institute of Computer Software">
<url ADR="http://dbgroup.cs.tsinghua.edu.cn" ID="1" INFO="Data Engineering"/>
<url ADR="http://keg.cs.tsinghua.edu.cn" ID="2" INFO="Knowledge Engineering"/>
<url ADR="http://166.111.68.91" ID="3" INFO="Design Automation of Computer and VLSI Circuits"/>
<url ADR="http://vis.cs.tsinghua.edu.cn" ID="4" INFO="Visualization and Computer Graphics"/>
<url ADR="http://soft.cs.tsinghua.edu.cn/soft/" ID="5" INFO="Software Engineering and System Software"/>
<url ADR="http://dbgroup.cs.tsinghua.edu.cn" ID="6" INFO="Data Engineering"/>
<url ADR="http://keg.cs.tsinghua.edu.cn" ID="7" INFO="Knowledge Engineering"/>
<url ADR="http://166.111.68.91" ID="8" INFO="Design Automation of Computer and VLSI Circuit"/>
<url ADR="http://vis.cs.tsinghua.edu.cn" ID="9" INFO="Visualization Technology and Computer Graphics"/>
</URL>
<URL adr="http://network.cs.tsinghua.edu.cn" id="8" info="Institute of Computer Networks"/>
</URL>
</crawledURLs>
\end{lstlisting}
\FloatBarrier
\lipsum[50]
\lipsum[50]
\lipsum[50]
\lipsum[50]
\lipsum[50]
\end{document}
编辑: