0

I want to horizontally center an image in my paper by the code below.

\documentclass[12pt,twocolumn,oneside,a4paper]{article}
...
...
...
\begin{figure*}[]
HK1706 (in 2017)
\centering
\includegraphics[width = 1.15\textwidth]{materials/aaa.jpg}
\caption{Map of the study area showing sampling stations and station numbers. }
\label{Figure 3}
\end{figure*}

But the image in pdf exported is off to the right like the attached image. It seems to be left-justified. How can I fix this and center the image?

A part of exported pdf

  • Welcome to TeX.SX! In fact, \textwidth is the width of the paper margin (the part to print the text, if I use a wrong word), so 1.15\textwidth is wider than the margin, or, your picture requires more space than expected. Therefore it can't be centered by \centering. I recommend using x\textwidth for 0 < x <= 1. Otherwise, you must need some more strategy. – user156344 Dec 26 '18 at 13:29
  • Welcome! It would make our lives simpler if you could make your minimal working example (MWE) self-contained. By this I mean that it include \begin{document}, \end{document} and all necessary packages (just graphicx in this case) so that we don't have to add these ourselves when we want to run/modify your code. – Circumscribe Dec 26 '18 at 13:46
  • 1
    Centering will work if you use wrap your image in a box of width \linewidth, with \makebox[\linewidth]{\includegraphics[…]{…}} btw. (See e.g. here.) – Circumscribe Dec 26 '18 at 13:49
  • Why don't you replace \includegraphics[width = 1.15\textwidth]{materials/aaa.jpg} with \includegraphics[width = 1.0\textwidth]{materials/aaa.jpg}? Put differently, what are you trying to achieve by making the image wider than the textblock? – Mico Dec 26 '18 at 14:08
  • \usepackage[export]{adjustbox} and then \includegraphics[width = 1.15\textwidth,center]{materials/aaa.jpg}. Please see Center figure that is wider than \textwidth. – Martin Scharrer Dec 26 '18 at 18:05
4

Just fool LaTeX with a \makebox[\linewidth]:

\documentclass[12pt,twocolumn,oneside,a4paper]{article}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure*}[]

HK1706 (in 2017)
\centering
\makebox[\linewidth]{\includegraphics[width = 1.15\textwidth]{materials/aaa.jpg}}
\caption{Map of the study area showing sampling stations and station numbers. }
\label{Figure 3}
\end{figure*}

\end{document} 

enter image description here

  • This code works! Thank you for this answer. – 加納大地 Dec 27 '18 at 1:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.