![floats パッケージと newenvironment コマンドを使用してカスタム環境定義を再利用: キャプション名の定義で停止](https://rvso.com/image/420756/floats%20%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%81%A8%20newenvironment%20%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E7%92%B0%E5%A2%83%E5%AE%9A%E7%BE%A9%E3%82%92%E5%86%8D%E5%88%A9%E7%94%A8%3A%20%E3%82%AD%E3%83%A3%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3%E5%90%8D%E3%81%AE%E5%AE%9A%E7%BE%A9%E3%81%A7%E5%81%9C%E6%AD%A2.png)
私は、長い単語リストと定義を格納するカスタム フロートを作成中です。これは、または(またはそれらの派生語)\multicols{n}
の代わりに使用して整理でき、定義の数と列の数に応じてページ間でうまく流れるようになります。ただし、他のフローティング環境と同様に、非常に大きい場合は、複数のページにまたがって流れることができません。一方、私が望んでいるのは、ドキュメント内のどこに配置してもリストが始まり、ページ数に関係なく、完了するまで続くことです。table
tabular
グーグルで検索していたら、こんな質問を見つけました:アルゴリズムタグと改ページ1 つの回答には、カスタム環境を定義することが含まれます。breakablealgorithm
これにより、複数のページにまたがって分散できるようになります。
私はこのコードを自分の文書に取り入れて調整し、今のところほとんど望み通りに動作していますが、元のコードとアルゴリズムキャプションに表示される名前を新しい名前に結び付けます。オルダリスト(単語リスト)。どの行が犯人かはわかっていると思いますが (MWE を参照)、新しい環境の名前を呼び出すように変更する方法がわかりません (オルダリストおよび\begin{bigwordlist}
の場合\endbigwordlist
)。
MWE:
\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
ではなくpackage を使用するべきだ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}