Generalhow to prevent frame from overlapping caption in SHOWEXPL ?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
latexian
Posts: 19
Joined: Wed Aug 05, 2009 7:57 am

how to prevent frame from overlapping caption in SHOWEXPL ?

Post by latexian »

Hi all,

I got very bad caption when using LTXexample in conjuction with its caption option.

Here is the minimal code snippet.

Code: Select all

\documentclass[10pt]{article} % Because the minimal class does NOT define figure environment I use article class instead. 

\usepackage{showexpl}
\lstset{%necessary settings
	explpreset={},
	breaklines=true,				
	frame=single,		
	numbers=left,pos=b}



\begin{document}

\begin{lstlisting}[caption={Using lstlisting. No problem in caption.}]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
\end{lstlisting}
\vspace{1cm}
\begin{LTXexample}[caption={Using LTXexample. Caption looks ugly.}]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
\end{LTXexample}

\end{document}
Please help me to handle it.

Note : only above caption has this problem, bottom caption works well.

Thank you in advance.

regards,

LATEXIAN

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

how to prevent frame from overlapping caption in SHOWEXPL ?

Post by gmedina »

Hi,

you can set an appropriate value for aboveskip:

Code: Select all

\documentclass{article}
\usepackage{showexpl}

\lstset{%necessary settings
   explpreset={},
   breaklines=true,            
   frame=single,      
   numbers=left,
   pos=b
}
   
\begin{document}

\begin{lstlisting}[caption={Using lstlisting. No problem in caption.}]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{lstlisting}
\vspace{1cm}
\begin{LTXexample}[caption={Using \texttt{aboveskip} fixs the problem.},frame=single,aboveskip=9pt]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{LTXexample}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
latexian
Posts: 19
Joined: Wed Aug 05, 2009 7:57 am

Re: how to prevent frame from overlapping caption in SHOWEXPL ?

Post by latexian »

@gmedina,

Thank for your reply.

You solved it! Great!
latexian
Posts: 19
Joined: Wed Aug 05, 2009 7:57 am

how to prevent frame from overlapping caption in SHOWEXPL ?

Post by latexian »

By inspection, I think that \fboxsep is the minimum value for aboveskip such that the frame and caption do NOT overlap each other.
Post Reply