1

I have the line

\noindent\parbox{\textwidth}{{\LARGE\textbf{\name}}}\hfill\begin{figure}[ht!]\includegraphics[width=2cm,height=2cm]{MyPic.jpg}\end{figure}

I want the "name" variable to be on the left, and the image to be on the right of the page. But it turns out the image goes on the left of the next line. How can I make it be in the same line as the "name", but to the right?

EDIT: Removing the begin{figure}

{\noindent\parbox{\textwidth}{{\LARGE\textbf{\name}}}\hfill\includegraphics[width=2cm,height=2cm]{MyPic.jpg}

yields the same result.

  • Your \parbox is set to fill \textwidth, which leaves no room to place the image against the right margin. Just set \noindent{\LARGE\textbf{\name}}\hfill\includegraphics[..]{...}%. – Werner Oct 29 '13 at 5:16
2

You don't need figure environment if not using caption. figure is a float and moves around. You don't need \parbox too.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\noindent\textbf{name} \hfill\includegraphics[width=2cm]{example-image-a}
\end{document}

enter image description here

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.