LaTex: Make image as wide as text column


\begin{figure*}[h!]

\centering

\includegraphics[width=\textwidth]{figures/UNETR_overview.png}

\caption{Placeholder for a figure. If you use a figure from a publication or other source you need to state this here in the caption.}

\label{fig1}

\end{figure*}

How can I make this the same width as my column? I use two-column layout but the image is as wide as the whole document.

Add Comment
2 Answer(s)
The image appears to be spreading across the entire document because you're using the "figure*" environment, which is designed for two-column layouts in LaTeX, making the image span the full width. If you aim to have the image the same width as a single column, use the "figure" environment instead. Here's how you can modify your existing code: ``` \begin{figure}[h!] \centering \includegraphics[width=\columnwidth]{figures/UNETR_overview.png} \caption{Placeholder for a figure. If you use a figure from a publication or other source you need to state this here in the caption.} \label{fig1} \end{figure} ``` Just replace "figure*" with "figure" and "textwidth" with "columnwidth" to fit the image in one column.
Answered on August 2, 2023.
Add Comment
In order to make an image as wide as the column in a two-column document in LaTex, you should use the `figure` environment and not the `figure*`. The difference between these two is that `figure*` spans both columns, while `figure` only spans a single column. So just by replacing `figure*` with `figure` in your code, your image should span the width of a single column. Here's your updated code: ```latex \begin{figure}[h!] \centering \includegraphics[width=\linewidth]{figures/UNETR_overview.png} \caption{Placeholder for a figure. If you use a figure from a publication or other source you need to state this here in the caption.} \label{fig1} \end{figure} ``` In this code: - `figure` means you want to add a picture. - `[h!]` tells LaTeX to place the figure "here" first, off the top of that column. If it cannot accommodate it here because of page break, it may place the figure at the next best location. - `\centering` centers your image. - `\includegraphics[width=\linewidth]{figures/UNETR_overview.png}` include the image. The `width=\linewidth` argument makes the image same width as the column. - `\caption` and `\label` gives a caption and a label to refer to it. Remember to use this `\usepackage{graphicx}` to use the `\includegraphics[]{}` command. If you haven't already, add it to the preamble of your document (the area before `\begin{document}`).
Answered on August 24, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.