TeX - LaTeX Asked on December 23, 2020
I am trying to put two listings side by side in a custom float using the float
package using minipage
s. What I am trying to do works fine inside a figure
(both captions appear) but inside my custom code
environment only the second ("Listing 2") caption appears.
MWE:
documentclass{article}
usepackage{lipsum}
usepackage{caption}
usepackage{listings}
usepackage{float}
floatstyle{plaintop}
newfloat{code}{thp}{lop}
floatname{code}{Listing}
begin{document}
lipsum
begin{code}[t]
begin{minipage}{0.45linewidth}
captionof{lstlisting}{Disappears}
Inside custom 1
end{minipage}hfill%
begin{minipage}{0.45linewidth}
captionof{lstlisting}{Appears}
Inside custom 2
end{minipage}
end{code}
begin{figure}[t]
begin{minipage}{0.45linewidth}
caption{Appears}
Inside figure 1
end{minipage}hfill%
begin{minipage}{0.45linewidth}
caption{Appears}
Inside figure 2
end{minipage}
end{figure}
end{document}
How can I solve this?
I found a solution using the newfloat
environment:
usepackage{newfloat}
DeclareFloatingEnvironment[fileext=frm,placement={tph},name=Frame]{myfloat}
…
begin{myfloat}[t]
centering
begin{minipage}{0.45linewidth}
captionof{lstlisting}{Appears}
Inside custom 1
end{minipage}hfill%
begin{minipage}{0.45linewidth}
captionof{lstlisting}{Appears}
Inside custom 2
end{minipage}
end{myfloat}
Correct answer by orestisf on December 23, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP