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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
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