2

I want to insert text in a defined (= set with a number, not just "bottom", "center" or "top") vertical position at the side of a figure. I managed to insert text at the side, but I can't figure out how to set the vertical position. Ideally, I would like to add different lines of text on the same side, each one with its position.

Here's what I did:

\documentclass{article}
\begin{document}

\begin{figure}[h]
text on the left side
\includegraphics[width=0.5\textwidth]{image}
\end{figure}

\end{document}

Alternatively, I can insert text and figure in a tabular, but again I don't know how to set the vertical position of the text:

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}

\begin{center}
\begin{tabular}{cc}   
text on the left & \includegraphics[width=0.5\textwidth]{image}
\end{tabular}
\end{center} 

\end{document}
1

You can use a normal tabular for the text on the left of the image and by specifying some distance after each newline \\ [<some v. distance>], you can control the vertical position of the text. Since pictures are normally placed above the baseline, you need to specify the [t] option from adjustbox package for the top text line to be adjusted with the top line of the image.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[export]{adjustbox}
\begin{document}

\begin{center}
\begin{tabular}[t]{r}
  text on the left1 \\[.5cm]
  text on the left2 \\[.5cm]
  text on the left3 \\
  text on the left4 \\[.5cm]
  text on the left5 
\end{tabular}
\includegraphics[width=0.5\textwidth,valign=t]{image}
\end{center} 

\end{document}

enter image description here

Another option would be using TiKZ like this:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{center}    
\begin{tikzpicture}
\node (p) {\includegraphics[width=0.5\textwidth]{image}};
\node [left] at ($(p.north west)!.1!(p.south west)$) {text on the left1};
\node [left] at ($(p.north west)!.3!(p.south west)$) {text on the left2};
\node [left] at ($(p.north west)!.5!(p.south west)$) {text on the left3};
\node [left] at ($(p.north west)!.7!(p.south west)$) {text on the left4};
\node [left] at ($(p.north west)!.9!(p.south west)$) {text on the left5};
\end{tikzpicture}    
\end{center}

\end{document}

with a similar (or better) output:

enter image description here

0

Without using TikZ or the tabular environment, one can use the minipage environment to split the page in two subpages. Then, the position of the text can be set using the classical spacing and positioning commands vspace, hspace, centering, flushleft, flushright, etc. For your example, one can code

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}

\begin{minipage}[b]{0.5\textwidth}
    \flushright
    text on the left 1

    text on the left 2

    \vspace{1em}
    text on the left 3
\end{minipage} 
\begin{minipage}{0.5\textwidth}
    \flushleft
    \includegraphics[]{image}
\end{minipage}

\end{document}

and obtain the following output:

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.