How to Place Text Between Two Pictures in LaTeX
At a glance
- 1. Load graphics
Use the graphicx package to insert image files with includegraphics.
- 2. Write in sequence
Place the first image, text, and second image in that order within the same paragraph or figure.
- 3. Set image sizes
Give both images a shared height or width so their sizes are predictable.
- 4. Adjust spacing
Use a small horizontal space or a centered tabular layout if the text needs vertical alignment.
To put text between two pictures in LaTeX, insert the first image, the text, and then the second image in sequence. If the three elements should stay together and have a caption, put them in a figure environment. A figure is a float, though, so LaTeX may move the whole group to a better page position.
The example below uses the sample images supplied by the mwe package. Replace their filenames with your own image files when adapting it.
Put the images and text in sequence
The graphicx package provides \includegraphics. The \quad commands add horizontal space on either side of the text; remove or change them to adjust the gap.
\documentclass{article}
\usepackage{graphicx}
\usepackage{mwe} % Provides example-image-a and example-image-b
\begin{document}
\begin{figure}[htbp]
\centering
\includegraphics[height=2cm]{example-image-a}
\quad
\textbf{Text between the pictures}
\quad
\includegraphics[height=2cm]{example-image-b}
\caption{Two pictures with text between them.}
\end{figure}
\end{document}
The [htbp] option suggests places where LaTeX may put the figure: here, at the top or bottom of a page, or on a page of figures. It does not force the figure to appear exactly at that point. Both images have the same height, which makes their displayed size consistent. You can instead set width, for example width=0.25\textwidth.
Place the group inline
If the pictures and text belong directly in a paragraph rather than in a floating figure, omit the figure environment and use the same sequence inline:
\includegraphics[height=1.5cm]{left-image}
\quad Some text \quad
\includegraphics[height=1.5cm]{right-image}
The image files must be available to LaTeX, typically in the same folder as the .tex file. Use their filenames, including extensions if needed. If the group is wider than the available line, LaTeX may produce an overfull line or push part of the content onto another line. Reduce the image sizes or place the group in a figure to avoid that problem.
Center the text vertically between the pictures
In a simple inline sequence, LaTeX aligns the elements along their text baselines. Since an image’s baseline is generally at its bottom edge, a short text label may sit low relative to tall pictures.
For a compact, predictable layout, use a three-column tabular with m columns from the array package. Unlike c columns, which center entries horizontally but align them by their baselines, m columns vertically center cell contents relative to the row. Load array in the preamble with \usepackage{array}.
\begin{figure}[htbp]
\centering
\begin{tabular}{>{\centering\arraybackslash}m{3cm} >{\centering\arraybackslash}m{4cm} >{\centering\arraybackslash}m{3cm}}
\includegraphics[height=2cm]{example-image-a} &
\textbf{Text between the pictures} &
\includegraphics[height=2cm]{example-image-b}
\end{tabular}
\caption{The middle cell centers the text vertically.}
\end{figure}
The m{...} column specifier sets a fixed column width and vertically centers the cell contents; >{\centering\arraybackslash} centers them horizontally. The & symbols separate the cells, and \\ would end a row if you added more rows. This approach also makes it straightforward to add a line break in the middle cell, such as \shortstack{First line\\Second line}.
When the text should be below the pictures
If you want a line of text between two rows of pictures, use line breaks or separate rows rather than placing everything in one inline sequence. For example, a tabular can hold the first image row, a text row, and a second image row. A figure can then keep the layout together and provide one caption.
For two pictures next to each other with a longer paragraph between them, decide whether the paragraph should sit in a narrow central column or wrap around an image. Those are different layouts: a three-column tabular is suited to a fixed central block, while text wrapping usually calls for a package such as wrapfig and has additional placement constraints.
Common mistakes
- Using
\includegraphicswithout loadinggraphicx: Add\usepackage{graphicx}in the preamble. - Expecting a figure to stay exactly where it is written: Figures float. Use the
floatpackage and[H]only when you specifically need to prevent floating; otherwise, choose a reasonable placement option such as[htbp]. - Forgetting image files: A filename such as
left-imagemust match a file LaTeX can find. The sample filenames in the complete example work because it loadsmwe. - Using spaces in the source for visible spacing: Ordinary source whitespace is not a reliable way to set a deliberate gap. Use commands such as
\quad,\hspace{...}, or a structured layout. - Making the total width too large: Add the widths of both images, the text, and the gaps. Keep their total within the available line or text width.
References
- The LaTeX Graphics Companion, 2nd edition, Michel Goossens, Frank Mittelbach, Sebastian Rahtz, Denis Roegel, and Herbert Voss
- CTAN: graphicx package
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.