Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

May be this is a very strange question. But I found this property is very useful to control the overlap element.

So I wonder if latex own this property as HTML div.

Do you have any better idea to solve the overlap problem. Sometime, I need to push some element back.

update:the MWE code



\documentclass{article}

\usepackage{listings}
\usepackage{courier}
\usepackage{caption}
\usepackage{xcolor} 
\usepackage{calc}

\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\parbox{\textwidth}{\colorbox{gray}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,
labelfont=white,
textfont=white,
singlelinecheck=false,
margin=0pt,
font={bf,footnotesize}
}

\newlength\tdima
\setlength\tdima{ \fboxsep+\fboxrule}

\lstset{
         basicstyle=\small\tt,
         tabsize=2,                  
         extendedchars=true,         
         breaklines=true,           
         mathescape,
         escapeinside={\%*}{*)},        
         showspaces=false,          
         showtabs=false,             
         showstringspaces=false,      
         columns=flexible,
         xleftmargin=\tdima,
         framextopmargin= 10pt,
         framexbottommargin=10pt,
         float=tp,                            % float setting
         frame=single,
}%

\begin{document}
\begin{lstlisting}[caption=overlap]
using namespace std;
int main(void)
{
    return 0;
}
\end{lstlisting}
\end{document}  


Output:

enter image description here

The caption overlap with the frame. And I want to push the caption back. Let the frame cover it. I don't want to use the \vskip to fine tuning the caption position.

share|improve this question
2  
Please give a minimal working example (MWE) where you want to control such an overlapping. –  canaaerus Jun 22 '12 at 18:09
    
@canaaerus please take a look at the revised edition question –  pythonee Jun 23 '12 at 7:21
    
I guess adding another \colorbox with a white background around the code should be the way to go, although I don't know how to achieve this with lstlisting. (As you can see the border is already in front of the label.) Maybe just adding backgroundcolor=\color{white} will do it. –  canaaerus Jun 23 '12 at 7:22

1 Answer 1

up vote 5 down vote accepted

Add a dimension to \fboxsep, as follows:

  \DeclareCaptionFormat{listing}{\fboxsep=1.2pt....

enter image description here

share|improve this answer
    
how do you figure out the 1.2pt –  pythonee Jun 24 '12 at 3:00
    
@pythonee Newton–Raphson's method:) i.e., it looked that much and I tried it out, didn't want to read through the code. –  Yiannis Lazarides Jun 24 '12 at 3:26
    
We usually name it as "trial and error" method. –  stalking is prohibited Jun 26 '12 at 17:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.