0

I have hacked together a small command that I can use to include graphics, scale them as I want and create a label for it and reference to it.

I use it like this:

As can be seen from
 \screencap{voltage-regulation}{Voltage Regulation Circuitry}.
the input is proteced against reverse polarity by the diode D1
and from thence the internal nominally 24 VDC voltage is derived with 
the pre-regulator U8/LM317.

The command is

\newcommand{\screencap}[2] {
\begin{figure}[htb] 
\includegraphics[scale=1.0]{#1.png}
\caption{#2}
\label{fig:#1}
\end{figure}
figure~\ref{fig:#1}
}

And it renders like this:

enter image description here

This is almost good enough but I don't want the image to appear in the middle of the paragraph. But after it, or basically anywhere after the place I refer to it but not inside the paragraph.

11
  • separate the command in to two and place the figure between paragraphs and the \ref where you refer to it. That is the standard latex markup, and does what you want here. – David Carlisle Jan 11 at 20:06
  • Note also you are missing % at ends of line in your definition (which is why your image shows a spurious space before the . after 4.1 – David Carlisle Jan 11 at 20:08
  • Have you tried to remove the h specifier from the figure placement options? Does \begin{figure}[tb] produce better results? – gernot Jan 11 at 22:29
  • @DavidCarlisle Two commands is what I had previously and that of course works but that was specifically what I tried to avoid cause it is more work and repetitive and goes against my programmer instinct of "do not repeat yourseld" or "single point of truth". – amateur99 Jan 12 at 4:54
  • @DavidCarlisle Thanks for the % / space tip, I did not know about that. – amateur99 Jan 12 at 4:55

Your Answer

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

Browse other questions tagged or ask your own question.