57

Different websites suggest using one of those two packages.

\usepackage{graphicx}
\usepackage{graphics}

What are differences between them? Which is better?

2
  • 4
    There used to be a preference for the "s" package for package writers, but it's a thing of the past. The "x" package is more powerful.
    – egreg
    Jul 14, 2011 at 19:57
  • 8
    graphicx also loads by default graphics
    – user2478
    Jul 14, 2011 at 20:04

4 Answers 4

62

Most modern people use graphicx!

graphicx is an extension of graphics. Moreover, while graphics sticks to the original TeX conventions concerning arguments, graphicx allows optional arguments according to the more transparent key=value scheme.

0
29

One of the major aims of LaTeX is to provide a layer of consistent syntax over the somewhat varying syntax provided by TeX primitives (and in the case of graphics inclusion by the various TeX engines and dvi dvrivers). For LaTeX2e there was a desire to make a driver independent graphics inclusion mechanism as part of the standard release (and described in the LaTeX book). None of the standard LaTeX commands (and at that time very few packages) used a key=value syntax so we wanted an interface with standard LaTeX command syntax.

However the most popular LaTeX2.09 contributed package for image inclusion at that time was epsfig which did have a key=value syntax, as did pstricks. It was clear that I couldn't replicate all the functionality of epsfig with \includegraphics without having an unwieldy collection of positional optional arguments, so I split the functionality putting the keyval version in graphicx described in the "Companion" books and the base functionality in graphics described in the "LaTeX Book". At the same time I developed the keyval parser into the separate keyval package to make it easy for other packages to use a similar syntax.

Move on a couple of decades and of course now several packages use key=value syntax, either using the original keyval parser or variants from xkeyval or pgfkeys or wherever so effectively that syntax convention is an accepted part of LaTeX syntax as understood by users and concerns over the use of it in a standard package may perhaps been seen as a temporary blip. But it's easier with hindsight, it wasn't so clear at the time that that was the way things would go...

Just use the x version:-)

22

This two packages belong together and AFAIK are only separated because of backwards compatibility to older code. The graphicx package (x for eXtended) is based on the graphics package and provides much more functionality. There is no reason to use graphics alone. All options of \includegraphics are only provided by graphicx.

0

Apart from the wonderful answers that has already been provided, I would like to point one thing more.

graphicx usepackage are capable of producing some "example images".

What I meant by that is as follows:

The usual way to include (the one that I do 😀) a figure is either to put the figure in the same folder where my .tex file is there or put in separate folder and give the path. This may be a problematic when we are going to post some problem, if we have encountered, onto a discussion platform like tex.stackexchange.com/- we may also have to give the figure file.

In particular this is what it is told in introduction page of mwe Package has to tell:

LATEX has a large online-community and people can find a lot of help from other users on places like comp.text.tex or http://tex.stackexchange.com/. In many cases the user with the problem is required to post a code example which shows the use-case, but nothing unrelated, and should be compilable by other people without extra effort. Such an example is often called a minimal working example (MWE), or sometimes only minimal example.

...

A problem with sharing MWEs appears if image files are included in the document (e.g. \includegraphics, figure environments etc.). Often the image is replaced with a replacement code like \rule{〈width〉}{〈height〉} or the demo option of graphicx is used to replace the image with an empty frame without trying to read the given image file. Both of these methods are a little cumbersome and have other issues.

So, in order to overcome this issue one may use graphic package, which gives us facility to use some example images.

enter image description here

The figure above can be reproduced by

\documentclass{article}
\usepackage{mwe}
%\usepackage{graphics}
%\usepackage{graphicx}
\begin{document}
     \centering{Difference between graphics and graphicx}
        \begin{figure}[h]
        \centering
        \includegraphics[scale=0.75]{example-grid-100x100bp}
        \caption{Image A}
    \end{figure}
    \begin{figure}[h]
        \centering
        \includegraphics[scale=0.15]{example-image-letter-numbered}
        \caption{Image B}
    \end{figure}
\end{document}

This code will work either with \usepackage{mwe} or \usepackage{graphicx}, but will not work if one have only \usepackage{graphics}.

The example images can be seen at the folder "C:\Program Files\MiKTeX\tex\latex\mwe", but I gather that there are much more to it as mentioned in this answer.

3
  • Not sure if this answer brings value to this specific question: It is a lot of text for little information. My recommendation is to make the answer very short and just link this (tex.stackexchange.com/questions/231738) or even just leave a comment (with the link) below one of the already existing answers. Apr 6, 2021 at 1:59
  • 2
    You don't need to include the mwe package in order to access the images. The reason why including mwe works is because it includes graphicx. The reason why the minimal example doesn't work with graphics is because it doesn't support the optional argument that graphicx supplies.
    – Werner
    Apr 6, 2021 at 4:55
  • 1
    This answer appears to not answer the question at all. You do not need to specify mwe package to use these images, and they work with graphics and graphicx so in what way is this showing any difference between the packages? Aug 18, 2021 at 8:11

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