TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


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!

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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.) – Dave Jarvis Dec 4 '10 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. – Dave Jarvis Dec 4 '10 at 23:26
@Dave: The space was from the \kern1em. – TH. Dec 5 '10 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. – Dave Jarvis Dec 5 '10 at 0:23
@Dave: You could put the rule in the margin instead. – TH. Dec 5 '10 at 0:34

Your Answer


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.