Background
Using the algorithm package to display source code listings.
Problem
The LaTeX (LyX) code (test.lyx
) is at: http://pastebin.com/QRWDhA7E
An example graphics (query.png
) file is at: http://i.stack.imgur.com/8RRL5.png
The result:
Notice the gap between the very first black line and the start of the blue background.
Related
Questions
- How do you make the caption flush with the top line?
- What is the proper way to make the caption flush with its bottom line? (I think I cheated by using
\vspace{-1ex}
.)
Thank you!
Best Answer
First of all many of us (if not even most of us) don't have LyX so better offer a LaTeX code instead. Second, better give a minimal example code, because usually reducing the code to it's minimum is the very first step when analyzing a LaTeX problem.
An reasonable example code showing the problem would be something like this:
But now let's take a look at your problem: The extra spaces are typeset by the "ruled" float style offered by the float package. One can change this by defining an own float style and making the algorithm environment using this one instead of the original one. I did that by copying the "ruled" style and modifying it:
So in total we have: (Please note that I have removed the extra
\vspace
of yours.)Please note that this code still contains 2x
\kern2pt
, one before and one after the algorithm body. If you don't like this extra vertical space, too, just remove them.