0

I am trying to center graphics in TexShop. This is the code that I am using but the graphics are not getting centering whatever I try to do.

 \begin{figure}[H]
    \centering
    \includegraphics[height = 2.3in]{/Users/LOCATION/Matrix1.png}   
    \caption{Generated Matrix}
\end{figure}

The code is giving me this image

Error Image

I tried using

\begin{center}
...
end{center}

instead of \centering but nothing seems to be fixing the problem.

EDIT 1 : Full Code

\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\begin{document}
 \begin{figure}[H]
     \centering
    \caption{Generated Matrix}  
    \includegraphics[height = 2.3in] {/Users/Max/Desktop/Math IA/PhysicsDrawings/Matrix1.png}
\end{figure}
\end{document}
Torbjørn T.
  • 206,688
Sumant
  • 145
  • 2
    Try \fbox{\includegraphics ... }. Do you get a lot of white space around the image? Also (unrelated to the problem): png isn't a good format for an image that contains text. eps or pdf would be better. – Ian Thompson Apr 24 '17 at 12:51
  • @campa The 'IA/PhysicsDrawings/Matrix1.png' is not part of the image – Sumant Apr 24 '17 at 12:52
  • 1
    Is LOCATION a path that includes spaces? – Torbjørn T. Apr 24 '17 at 12:55
  • 1
    Texshop is only the editor. The question should be completely independent from the editor but not independent from the image file and it's real name in a MWE. – Schweinebacke Apr 24 '17 at 13:07
  • hard to tell as you have not shown the code that produced output that you show, but it looks like your path has a space in it, but isn't being used so \includegraphics[height = 2.3in]{Matrix1.png} should worrk. – David Carlisle Apr 24 '17 at 13:37
  • @IanThompson I tried using \fbox but that didn't seem to help. Here is more of the code including the actual location of the file... \begin{figure}[H] \centering \caption{Generated Matrix} \includegraphics[height = 2.3in] {/Users/Max/Desktop/Math IA/PhysicsDrawings/Matrix1.png} \end{figure}

    Is there any problems with this?

    – Sumant Apr 24 '17 at 13:43
  • Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. You can replace the actual file with example-image. – erik Apr 24 '17 at 13:44
  • When you used \fbox, did you see white space between the image and the frame or not? – Ian Thompson Apr 24 '17 at 13:47
  • @erik Thanks for adding that I edited the question to show more of the code – Sumant Apr 24 '17 at 13:48
  • 2
    I suggest you take a look at the question How to include graphics with spaces in their path? – erik Apr 24 '17 at 13:49
  • @IanThompson Yeah, there was a lot of white space between the frame and the image – Sumant Apr 24 '17 at 13:49
  • 1
    @erik Thanks for the comment! That completely fixed the formatting... Didn't realise that spaces in the title would cause a problem with my image. – Sumant Apr 24 '17 at 13:52

0 Answers0