1

I have following problem:

\begin{figure}[htbp]
\centerline{\includegraphics[width=\columnwidth]{relations.png}}
\caption{Example of a figure caption.}
\label{fig}
\end{figure}

the image is a little bit too big if I do this above.
Instead, I'd like the width to be about 10px smaller.

I tried the following:

\begin{figure}[htbp]
\centerline{\includegraphics[width=\columnwidth - 10px]{relations.png}}
\caption{Example of a figure caption.}
\label{fig}
\end{figure}

But it doesn't work.

How can I adjust the width of the image by a few pixels?

6
  • Try width=.95\linewidth. Commented Jan 4, 2023 at 16:30
  • Welcome to TeX.SE!
    – Mensch
    Commented Jan 4, 2023 at 16:30
  • @RaffaeleSantoro thank you for your help! But I have to ask: isn't it possible to use minus and plus? Commented Jan 4, 2023 at 16:35
  • 4
    width=\dimexpr \columnwidth -10pt. Commented Jan 4, 2023 at 16:54
  • @YasinSahin Unrelated to your question, but better use \centering\includegraphics[...]{...} instead of \centerline Commented Jan 4, 2023 at 19:02

1 Answer 1

1

To reduce the width of the image by 10px, you can use the "\dimexpr" command to subtract 10px from the width of the image.

Example:

\begin{figure}[htbp]
  \centerline{\includegraphics[width=\dimexpr\columnwidth-10px\relax]{relations.png}}
  \caption{Example of a figure caption.}
  \label{fig}
\end{figure}

You can also use the "\hspace*{-10px}" command to shift the image 10px to the left, which will effectively reduce the width of the image by 10px. Here is an example of how you can do this:

\begin{figure}[htbp]
  \centerline{\hspace*{-10px}\includegraphics[width=\columnwidth]{relations.png}}
  \caption{Example of a figure caption.}
  \label{fig}
\end{figure}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .