0

I'm using tikzpicture to write some text over an image.

Does anyone of you know how to position a text node so that the last letter of a possible variable-length sentence (of that text node) is always at the same distance from the right margin of the document?

Here's my current code:

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage{tikz}
\usepackage{titling}
\usepackage[margin=0.9in]{geometry}

\title{Article Y}
\author{Author X}
\date{\vspace{-2ex}{\small \today}}

\setlength{\droptitle}{-3.8em}

\pretitle{%
    \begin{center}
    \LARGE
    \begin{tikzpicture}
        \draw (0, 0) node[inner sep=0] {\includegraphics[width=\textwidth]{images/my-logo}};
        \draw (5.5, -0.1) node {{\normalsize A possible variable sentence...}};
    \end{tikzpicture}\\
    [\bigskipamount]
}

\posttitle{\end{center}}


\begin{document}
\maketitle

\subsection*{Sec 1}

\subsection*{Sec 2}

\end{document}

If it's not possible to do it using tikzpicture, alternatives are welcome.

2
  • nodes with right aligned text and positioned left of selected distance? can yo show us, what you try so far?
    – Zarko
    Oct 2, 2017 at 19:02
  • 1
    Please do add your code. Oct 2, 2017 at 19:05

2 Answers 2

1

These nodes are 2cm from the right margin of the page. You need to compile twice. If you want another reference point, change the coordinate yline:

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage{tikz}
\usepackage{titling}
\usepackage[margin=0.9in]{geometry}

\title{Article Y}
\author{Author X}
\date{\vspace{-2ex}{\small \today}}

\setlength{\droptitle}{-3.8em}

\pretitle{%
    \begin{center}
    \LARGE
    \begin{tikzpicture}[remember picture]
        \draw (0, 0) node[inner sep=0] {\includegraphics[width=\textwidth]{example-image}};
        \coordinate (yline) at ([xshift=-2cm]current page.east);
        \node[overlay,anchor=east] at (0,0 -| yline){{\normalsize A possible variable sentence...}};
        \node[overlay,anchor=east] at (0,-0.5 -| yline){{\normalsize short}};
        \node[overlay,anchor=east] at (0,-1 -| yline){{\normalsize a bit longer}};
    \end{tikzpicture}\\
    [\bigskipamount]
}

\posttitle{\end{center}}


\begin{document}
\maketitle

\subsection*{Sec 1}

\subsection*{Sec 2}

\end{document}

enter image description here

3

If you just want to place text on top of the image, tikz might be a bit overkill.

\documentclass{article}

\usepackage{graphicx}
\begin{document}

\setlength{\unitlength}{\textwidth}%
 \begin{picture}(1,0.568382)%
    \put(0,0){\includegraphics[width=\textwidth]{example-image}}%
        \put(0.97,0.1){\makebox(0,0)[rb]{sentence}}%
        \put(0.97,0.2){\makebox(0,0)[rb]{long sentence}}%
 \end{picture}

\end{document}
0

You must log in to answer this question.