我正在创建一个自定义浮动框,用于存放长长的单词和定义列表,这样我就可以用它们来组织单词和定义,\multicols{n}
而不是使用table
或tabular
(或任何派生词),这样它就可以根据定义的数量和列数很好地跨页流动。但是,与其他浮动环境一样,如果它们非常大,它们就会拒绝跨多个页面流动,而我想要的是列表从我将其放置在文档中的任何地方开始,并一直持续到完成,无论有多少页。
我在谷歌搜索时发现了这个问题:算法标签和分页符,其中一个答案包括定义一个自定义环境,breakablealgorithm
这使得它们可以分布在多个页面上。
我把这段代码调整到我的文档中,到目前为止,一切都按照我想要的方式工作,只是我无法弄清楚如何打破原始代码与算法标题中出现的名称并将其与我的新名称联系起来:奥达利斯蒂(单词表)。我想我知道哪一行是罪魁祸首(参见 MWE),但我一直无法找到如何修改它来调用我的新环境的名称(奥达利斯蒂为\begin{bigwordlist}
和\endbigwordlist
)。
梅威瑟:
\documentclass[12pt]{book}
\usepackage[LY1,T1]{fontenc}
\usepackage[icelandic]{babel}
\usepackage{lmodern}
\usepackage{multicol}
\usepackage{float}
\usepackage{algorithm} % if I delete this it breaks at \caption
\floatstyle{plain}
\newfloat{wordlist}{tbhp}{lol}[chapter]
\floatname{wordlist}{Orðalisti}
\makeatletter
\newenvironment{bigwordlist}
{
\refstepcounter{wordlist}
\renewcommand{\caption}[2][\relax]{
{\center{\ALG@name~\thewordlist}{:} ##2\par}% problematic line
\ifx\relax##1\relax
\addcontentsline{lol}{wordlist}{\protect\numberline{\thewordlist}##2}
\else
\addcontentsline{lol}{wordlist}{\protect\numberline{\thewordlist}##1}
\fi
}
}{
}
\makeatother
\begin{document}
\chapter{List chapter}
This is a short list:
\begin{wordlist}
\sffamily
Master cleanse edison \\ bulb bicycle rights ad \\ affogato ethical \\ Truffaut mustache fugiat \\ skateboard shaman man braid \\
\rmfamily
\label{listi:short}
\caption{this is a short list}
\end{wordlist}
This is a very long list that I have:
\begin{bigwordlist}
\begin{footnotesize}
\begin{multicols}{2}
\sffamily
\noindent
Master cleanse edison \\ bulb bicycle rights ad \\ affogato ethical \\ Truffaut mustache fugiat \\ skateboard shaman man braid \\
tumeric irure sunt \\ enamel pin \\ in taiyaki \\ Tacos velit four\\ loko listicle health \\ goth narwhal \\ XOXO \\ esse mumblecore ea \\
bitters +1 \\ Organic sartorial authentic \\ waistcoat officia \\ reprehenderit pork \\ belly helvetica mumblecore \\ Chillwave dreamcatcher marfa \\
ea artisan kickstarter \\ thundercats \\ lo-fi tofu \\ before they sold out \\ air plant \\ woke offal \\ Typewriter truffaut quinoa \\
everyday carry \\ ethical narwhal in \\ Selfies la croix \\ cray salvia subway tile \\ bitters vexillologist \\ enim tumeric anim \\ Craft beer \\
meh lorem \\ air plant \\ adaptogen stumptown \\ cold-pressed chartreuse\\ deserunt chicharrones forage \\ Lomo cupidatat \\ subway tile \\
locavore ut \\ 90's keffiyeh ramps \\ consectetur truffaut \\ skateboard \\ pour-over slow-carb \\ irony subway \\ tile adipisicing aliquip \\
Yuccie vinyl shoreditch \\ mumblecore \\ sriracha \\ tote bag \\ heirloom gluten-free wayfarers \\ letterpress glossier \\ Green juice taiyaki \\
chambray actually \\ letterpress \\ XOXO lyft \\ duis af sed \\ flannel \\ gentrify deep v. Dreamcatcher \\ cornhole flexitarian \\ mumblecore street art\\
raw denim \\ Live-edge \\ vegan portland \\ cray et yuccie \\ beard \\ shabby chic qui \\ selvage roof party \\ sunt \\ Pour-over yr \\ mollit raclette \\
beard brooklyn \\ hell of hexagon pork belly celiac \\ Succulents chambray\\ incididunt coloring book \\ disrupt flexitarian taiyaki sed \\ Before they sold out \\
edison bulb \\ prism \\ farm-to-table \\ do coloring book \\ Tattooed lorem \\ cred tacos \\ before they sold out \\ viral \\ man bun \\ cray enamel \\
pin wolf \\ Tofu wolf\\ semiotics id typewriter \\ XOXO \\ you probably haven't heard of them \\ tote bag \\ williamsburg \\ Asymmetrical heirloom \\
taxidermy cred \\ ea occaecat squid \\ fugiat labore \\ PBR\&B godard \\ the end
\rmfamily
\end{multicols}
\end{footnotesize}
\label{listi:long}
\caption{this is a long list}
\end{bigwordlist}
\listof{wordlist}{Orðalistaskrá}
\end{document}
关于创建新类型的浮动环境的一些评论和答案说人们应该使用包newfloat
而不是float
,我也尝试用它设置相同类型的环境。但是,我仍然需要定义一个可中断的版本,因为我看不出我可以在其中实现开箱即用的分页功能。
答案1
使用\fname@wordlist
而不是\ALG@name
。那么您就不再需要了\usepackage{algorithm}
。
\documentclass[12pt]{book}
\usepackage[LY1,T1]{fontenc}
\usepackage[icelandic]{babel}
\usepackage{lmodern}
\usepackage{multicol}
\usepackage{float}
\floatstyle{plain}
\newfloat{wordlist}{tbhp}{lol}[chapter]
\floatname{wordlist}{Orðalisti}
\makeatletter
\newenvironment{bigwordlist}
{
\refstepcounter{wordlist}
\renewcommand{\caption}[2][\relax]{
{\center{\fname@wordlist~\thewordlist}{:} ##2\par}% problematic line
\ifx\relax##1\relax
\addcontentsline{lol}{wordlist}{\protect\numberline{\thewordlist}##2}
\else
\addcontentsline{lol}{wordlist}{\protect\numberline{\thewordlist}##1}
\fi
}
}{
}
\makeatother
\begin{document}
\chapter{List chapter}
This is a short list:
\begin{wordlist}
\sffamily
Master cleanse edison \\ bulb bicycle rights ad \\ affogato ethical \\ Truffaut mustache fugiat \\ skateboard shaman man braid \\
\rmfamily
\label{listi:short}
\caption{this is a short list}
\end{wordlist}
This is a very long list that I have:
\begin{bigwordlist}
\begin{footnotesize}
\begin{multicols}{2}
\sffamily
\noindent
Master cleanse edison \\ bulb bicycle rights ad \\ affogato ethical \\ Truffaut mustache fugiat \\ skateboard shaman man braid \\
tumeric irure sunt \\ enamel pin \\ in taiyaki \\ Tacos velit four\\ loko listicle health \\ goth narwhal \\ XOXO \\ esse mumblecore ea \\
bitters +1 \\ Organic sartorial authentic \\ waistcoat officia \\ reprehenderit pork \\ belly helvetica mumblecore \\ Chillwave dreamcatcher marfa \\
ea artisan kickstarter \\ thundercats \\ lo-fi tofu \\ before they sold out \\ air plant \\ woke offal \\ Typewriter truffaut quinoa \\
everyday carry \\ ethical narwhal in \\ Selfies la croix \\ cray salvia subway tile \\ bitters vexillologist \\ enim tumeric anim \\ Craft beer \\
meh lorem \\ air plant \\ adaptogen stumptown \\ cold-pressed chartreuse\\ deserunt chicharrones forage \\ Lomo cupidatat \\ subway tile \\
locavore ut \\ 90's keffiyeh ramps \\ consectetur truffaut \\ skateboard \\ pour-over slow-carb \\ irony subway \\ tile adipisicing aliquip \\
Yuccie vinyl shoreditch \\ mumblecore \\ sriracha \\ tote bag \\ heirloom gluten-free wayfarers \\ letterpress glossier \\ Green juice taiyaki \\
chambray actually \\ letterpress \\ XOXO lyft \\ duis af sed \\ flannel \\ gentrify deep v. Dreamcatcher \\ cornhole flexitarian \\ mumblecore street art\\
raw denim \\ Live-edge \\ vegan portland \\ cray et yuccie \\ beard \\ shabby chic qui \\ selvage roof party \\ sunt \\ Pour-over yr \\ mollit raclette \\
beard brooklyn \\ hell of hexagon pork belly celiac \\ Succulents chambray\\ incididunt coloring book \\ disrupt flexitarian taiyaki sed \\ Before they sold out \\
edison bulb \\ prism \\ farm-to-table \\ do coloring book \\ Tattooed lorem \\ cred tacos \\ before they sold out \\ viral \\ man bun \\ cray enamel \\
pin wolf \\ Tofu wolf\\ semiotics id typewriter \\ XOXO \\ you probably haven't heard of them \\ tote bag \\ williamsburg \\ Asymmetrical heirloom \\
taxidermy cred \\ ea occaecat squid \\ fugiat labore \\ PBR\&B godard \\ the end
\rmfamily
\end{multicols}
\end{footnotesize}
\label{listi:long}
\caption{this is a long list}
\end{bigwordlist}
\listof{wordlist}{Orðalistaskrá}
\end{document}