3

I am trying to place some text (a credit-line) on the lower right corner of (many) pictures. The text should be right-aligned with the right edge of the picture. I tried things like

\documentclass[a3paper,english]{article}
\usepackage[percent]{overpic}

\begin{document}

    \begin{overpic}[width=0.5\textwidth]{#1}%
        \put (98,2) {\makebox(0,0)[r]{\footnotesize some text}}%
    \end{overpic}%

\end{document}

where #1 is the filename of the figure. This seems to work if the the picture has landscape format. If it is in portrait the text appears outside on the right. It seems that the coordinates used by put are the same in x- and y-direction and determined by the larger of the dimensions of the images. Is there a way to correctly right justify the text with the right edge of the pictures?

5

I see no need for extra packages in this case (if I understand the question). You can use just

\includegraphics[width=5cm]{example-image-a}% <--important!
\makebox[0pt][r]{\footnotesize some text}

The comment sign is important in order to avoid spurious space. A little \raisebox may be helpful. So e.g. the following code

\documentclass[convert={size=640}]{standalone}

\usepackage{graphicx}

\begin{document}

\includegraphics[width=5cm]{example-image-a}%
\makebox[0pt][r]{\footnotesize some text}

\includegraphics[angle=90,width=5cm]{example-image-a}%
\raisebox{1pt}{\makebox[0pt][r]{\footnotesize some other text}}

\end{document}

generates enter image description here

2

Needless to say, the TikZ package can handle this and more. inner sep controls the gap between the node contents and the edge.

\documentclass[a3paper,english]{article}
\usepackage{tikz}
\usepackage{mwe}

\begin{document}

 \noindent\hfil
    \begin{tikzpicture}
        \node[inner sep=0pt] (picture) {\includegraphics[width=0.3\textwidth]{example-image}};
        \node[above left] at (picture.south east) {some text};
    \end{tikzpicture}%
\hfil
    \begin{tikzpicture}
        \node[inner sep=0pt] (picture) {\includegraphics[angle=90,width=0.3\textwidth]{example-image}};
        \node[above left] at (picture.south east) {some text};
    \end{tikzpicture}%
\hfil
    \begin{tikzpicture}[every node/.style={rotate=90}]
        \node[inner sep=0pt] (picture) {\includegraphics[width=0.3\textwidth]{example-image}};
        \node[above left] at (picture.south east) {some text};
    \end{tikzpicture}%
\end{document}

ovelay with tikz

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.