Using LyX to write a book. The source code listings shown in the book are graphics. The graphics should have a vertical rule beside them. But only graphics that are embedded within an Algorithm float. The code for the float resembles:


\caption{\label{alg:Query-with-Formatting}Query with Formatting}


There are scores of these example source code snippets, with more to come. Adding code to each one, manually, is undesirable.


Listing 1.1 in the following figure shows the placement character [H] nestled between the vertical rule and the graphic:


The preamble used:

% Determine if the image is too wide for the page.

% Resize figures that are too wide for the page.

% Do not centre graphics within Algorithm floats.    
  \vrule width 1em



How do you eliminate the [H] argument so that the \vrule appears flush with the graphic, and placed "Here definitely"? (I have managed to do this in other ways, but then the graphics are no longer "Here definitely.")

Thank you!

1 Answer 1


I think what you want to do here is change

  \vrule width 1em


                \vrule width1em

This only works for graphics because TeX treats them as a single box. For a more normal usage of algorithm which contains an algorithmic environment, the coderule environment from the previous question would be more suitable.

  • Thank you. Almost works. The [H] parameter is gone, but the vertical space it imposed remains. (That is, there is space between the image and \vrule.) Dec 4, 2010 at 23:23
  • Caused by width1em rather than width 1em? Or caused by \kern1em. I changed the first and removed the second. It works now, thank you. Dec 4, 2010 at 23:26
  • @Dave: The space was from the \kern1em.
    – TH.
    Dec 5, 2010 at 0:20
  • Sadly, I had to shelve the idea of a LaTeX-based \vrule altogether, as it pushes the longer listings into the page margins. Dec 5, 2010 at 0:23
  • @Dave: You could put the rule in the margin instead.
    – TH.
    Dec 5, 2010 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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