# Unwanted graphic offset [duplicate]

I'm getting a small difference in horizontal alignment when using the two ways of placing an image as shown in my code below. I know it doesn't look like there's much point in what I've done, but this is just a minimal example showing the problem.

Anyone know why this happens? Or how to fix it?

Thanks for any help.

\documentclass{article}
\usepackage{graphicx,caption}

\newcommand{\scalebar}[1]{\includegraphics[width=0.5\textwidth]{#1}
}

\begin{document}

\begin{figure}[!hptb]
\centering
\includegraphics[width=0.5\textwidth]{image}
\caption{}
\label{normalImage}
\end{figure}

\begin{figure}[!hptb]
\centering
\scalebar{{image}}
\caption{}
\label{imageFromCommand}
\end{figure}

\end{document}

• Shall I let egreg do the honors? You need to put a % immediately after { (before \begin{tikzpicture}) and after \end{tikzpicture} or latex will add a space each time. – John Kormylo Jun 28 '14 at 15:08
• Hi John, I'm just commenting to say that your answer is right even though it looks a bit odd now that I've edited my original post. I realised that it wasn't anything to do with tikz and changed my example. It was because of my spacing though, thank you! – Cog77 Jun 28 '14 at 15:16
• After you make the mistake a few dozen times... – John Kormylo Jun 28 '14 at 15:21
• Surely @JohnKormylo should be egreg in this case? – cfr Jun 28 '14 at 17:39
• @JohnKormylo Please, go forth! – egreg Jun 28 '14 at 21:05