Background
Dozens of source code snippets inserted into a document as images inside of Algorithm floats. Other images are screen captures, inserted as Graphics floats, to make a distinction. All Graphic floats should be centred, thus the preamble contains:
% Resize figures that are too wide for the page.
\let\oldincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{%
\oldincludegraphics[width=\ScaleIfNeeded]{#2}
\centering
}
This works, as ScaleIfNeeded is defined elsewhere, resulting in all images being centred, including the Algorithm images.
Problem
The Algorithm floats also contain images, and these images are centred, which is undesirable. The code for each Algorithm resembles:
\begin{algorithm}[H]
\includegraphics{source/sql/query-formatted.sql.png}
\caption{\label{alg:Query-with-Formatting}Query with Formatting}
\end{algorithm}
Ideas
Tried:
% Centre algorithms.
\let\oldalgorithm\algorithm
\let\endoldalgorithm\endalgorithm
\renewenvironment{algorithm}[1][ht]{%
\begin{flushleft}
\oldalgorithm[#1]
\end{flushleft}
}%
{\endoldalgorithm}
This results in a number of errors ("Missing } inserted", amongst others).
Question
How can images embedded exclusively within Algorithm floats be left-justified?
Bonus Question
How can a thick, left-hand vertical rule (or any stylistic change) be made to the Algorithm floats? For example, the left-hand border on the "batch source text" from this indirectly-related question. (Or any source code snippets on SuperUser.com, for that matter.)
Thank you!
coderulesepautomatically apply. Thanks! – Dave Jarvis Dec 04 '10 at 19:14\vrule width 1emto the\expandaftersection. The\vruleis split from the image with[H]. – Dave Jarvis Dec 04 '10 at 19:48\algorithmand\endalgorithmas before and then use\renewenvironmentto capture the contents of the algorithm in a\vboxas I did incoderule. Then, after the\egroupwhich ends the\vbox, use the saved\algorithmand\endalgorithmalong with the rule and the box. (I don't use LyX though so I'm not really sure what you can and cannot do.) – TH. Dec 04 '10 at 21:42