![Повторное использование пользовательского определения среды с помощью пакета floats и команды newenvironment: зависание на определении имени заголовка](https://rvso.com/image/420756/%D0%9F%D0%BE%D0%B2%D1%82%D0%BE%D1%80%D0%BD%D0%BE%D0%B5%20%D0%B8%D1%81%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5%20%D0%BF%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D1%8C%D1%81%D0%BA%D0%BE%D0%B3%D0%BE%20%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%B8%D1%8F%20%D1%81%D1%80%D0%B5%D0%B4%D1%8B%20%D1%81%20%D0%BF%D0%BE%D0%BC%D0%BE%D1%89%D1%8C%D1%8E%20%D0%BF%D0%B0%D0%BA%D0%B5%D1%82%D0%B0%20floats%20%D0%B8%20%D0%BA%D0%BE%D0%BC%D0%B0%D0%BD%D0%B4%D1%8B%20newenvironment%3A%20%D0%B7%D0%B0%D0%B2%D0%B8%D1%81%D0%B0%D0%BD%D0%B8%D0%B5%20%D0%BD%D0%B0%20%D0%BE%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%B8%D0%B8%20%D0%B8%D0%BC%D0%B5%D0%BD%D0%B8%20%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BA%D0%B0.png)
Я нахожусь в процессе создания пользовательского плавающего элемента для размещения длинных списков слов и определений, которые я мог бы организовать \multicols{n}
вместо table
или tabular
(или любых производных от них), чтобы он хорошо перетекал по страницам в зависимости от количества определений и количества столбцов. Однако, как и в случае с другими плавающими средами, если они очень большие, они отказываются перетекать через несколько страниц, тогда как я хочу, чтобы список начинался там, где я его размещаю в документе, и продолжался до конца, сколько бы страниц это ни было.
Во время поиска в Google я нашел такой вопрос:Тег алгоритма и разрыв страницы, где один из ответов включает определение пользовательской среды, 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}
Некоторые комментарии и ответы о создании новых типов плавающих сред говорили, что людям лучше использовать package 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}