Graphic Block
An graphic block is composed of a graphic from a graphics file only.
\includegraphics command is used to insert graphics of the specified graphics file to the LaTeX document. The typical image manipulating packages that supporting
\includegraphics are
graphics and
graphicx. The
\graphicspath command can also be used to specify the locations of graphics file. While
\begin{} environment is used to specify the form of g title block to be displayed.
usepackage
graphics Package
\includegraphics{filename}
\includegraphics[urx,ury]{filename}
\includegraphics[llx,lly][urx,ury]{filename}
\includegraphics*{filename}
\includegraphics*[urx,ury]{filename}
\includegraphics*[llx,lly][urx,ury]{filename}
graphicx Package
\includegraphics{filename}
\includegraphics[key-value list]{filename}
\includegraphics*{filename}
\includegraphics*[key-value list]{filename}
Arguments
*
* is an optional flag to indicate that the starred form
\includegraphics will clip the graphic to the size specified. Otherwise any part of the graphic that is outside the box of the specified size will over-print the surrounding area.
filename
filename is used to specify the graphics file to be included by
\includegraphics in the LaTex document.
File Searching Path
Path information can also be specified in
filename. The default graphics file searching path is same as the location of the LaTeX document. However, additional graphics file searching paths can also be specified by the
\graphicspath command.
File Specification
If
filename includes spaces, then
filename should be double quoted, e.g.
\includegraphics{"file name.ext"}. The type of graphic to be included by
\includegraphics is determined by splitting
filename on first dot. If there is no dot in
filename,
\includegraphics command will try a sequence of supported extension until a file with the that extension is found. The list of filename extensions for trying can be specified by
\DeclareGraphicsExtensions.
If there are more than one dot in
filename, dots before the extenson should be hide by curly brace, e.g.
\includegraphics{{file.name}.ext}. For using
graphicx package, the options
type and
ext.
Besides, package
grffile, Extended file name support for graphics (legacy package) may be used when needed.
Graphic Block Examples
Examples
graphics Example
\documentclass{article}
\usepackage{graphics}
\graphicspath{{./images/}}
\begin{document}
\includegraphics{sidewaylogo2020.png}
\includegraphics{sideway logo2020.png}
\includegraphics{images/sidewaylogo2020.png}
\includegraphics{images/sideway logo2020.png}
\includegraphics{sideway logo.2020}
\includegraphics{sideway.logo 2020}
\includegraphics{"images/sideway logo2020.png"}
\includegraphics{"sideway logo.2020.png"}
\includegraphics{{sideway.logo 2020}.png}
\end{document}
graphicx Example
\documentclass{article}
\usepackage{graphicx}
\graphicspath{{./images/}}
\begin{document}
\includegraphics{sidewaylogo2020.png}
\includegraphics{sideway logo2020.png}
\includegraphics{images/sidewaylogo2020.png}
\includegraphics{images/sideway logo2020.png}
\includegraphics{sideway logo.2020}
\includegraphics{sideway.logo 2020}
\includegraphics{"images/sideway logo2020.png"}
\includegraphics{"sideway logo.2020.png"}
\includegraphics{{sideway.logo 2020}.png}
\end{document}
graphics Options
[urx,ury]
Optional
graphics argument. If only one optional argument is specified then the argument is used to specify the top-right corner coordinates of the image,
[urx,ury] in form of a TeX dimensions pair. While the lower-left corner coordinates of the images is assumed to be at (0,0). The default unit is
bp, if the units are omitted.
[llx,lly]
Optional
graphics argument. If two optional arguments are specified then the first argument is
[llx,lly] and the argument is used to specify the lower-left corner coordinates of the image,
[llx,lly] in form of a TeX dimensions pair. And the second argument is
[urx,ury] and the argument is used to specify the top-right corner coordinates of the image,
[urx,ury] in form of a TeX dimensions pair.
graphicx [key-value list] Option
Optional
graphicx argument. The options are read from left to right.
The included graphic is bounded by a bounding box by LaTeX for manipulating in sa LaTeX document.
General Options
Note that a graphic is placed by LaTeX into a box, which is traditionally referred to as its bounding box (distinct from the PostScript BoundingBox described below). The graphic’s printed area may go beyond this box, or sit inside this box, but when LaTeX makes up a page it puts together boxes and this is the box allocated for the graphic.
width
width is used to specify the width of bounding box by which the included graphic will be bound. The standard TeX dimensions can used, and page layout parameters, such as
\linewidth, or
\columnwidth. By using the
calc package, arithmetic expression can also be used.
height
height is used to specify the height of bounding box by which the included graphic will be bound. The standard TeX dimensions can used, and page layout parameters, such as
\pageheight, or
\textheight. By using the
calc package, arithmetic expression can also be used.
height is the height above the baseline.
totalheight
totalheight is used to specify the height of bounding box above the baseline. The specified height plus depth is the height of bounding box by which the included graphic will be bound. The standard TeX dimensions can used.
depth is the depth below the baseline.
keepaspectratio
keepaspectratio is used to specify the aspect ratio of graphic. Or
keepaspectratio is set to
true. And both width and height (or totalheight) is given as options, then LaTeX will make the graphic is as large as possible without distortion. That is, LaTeX will ensure that neither is the graphic wider than width nor taller than height (or totalheight).
scale
scale is used to spectify the factor by which to scale the graphic. This number may be any value; a number between 1 and 0 will shrink the graphic and a negative number will reflect it.
angle
angle is used to specify the angle by which to rotate the graphic. The angle is taken in degrees and counterclockwise. The graphic is rotated about its origin; see that option. Besides.
\rotatebox is also the command used to rotate.
origin
origin is used to specify the point of the graphic about which the rotation happens. Possible values are
l for left,
r for right,
b for bottom,
c for center,
t for top, and
B for baseline. The parameter can be any string containing one or two of the possible values. The default is
lB. Besides,
\rotatebox command can be used to rotate about an arbitrary point.
graphicx General Options Examples
width, height Example
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\frame{\includegraphics{{images/sidewaylogo2020}}}
\frame{\includegraphics{{images/sidewaylogo2020}}}
\frame{\includegraphics{{images/sidewaylogo2020}}}\frame{\includegraphics[width=20mm]{{images/sidewaylogo2020}}}
\frame{\includegraphics{{images/sidewaylogo2020}}}
\frame{\includegraphics{{images/sidewaylogo2020}}}
\frame{\includegraphics{{images/sidewaylogo2020}}}\frame{\includegraphics[height=20mm]{{images/sidewaylogo2020}}}
\frame{\includegraphics{{images/sidewaylogo2020}}}
\frame{\includegraphics{{images/sidewaylogo2020}}}
\frame{\includegraphics{{images/sidewaylogo2020}}}\frame{\includegraphics[width=20mm, height=20mm]{{images/sidewaylogo2020}}}
\end{document}
height totalheight angle Example
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\fbox{\includegraphics[height=11mm]{{sidewaylogo2020}}}
\fbox{\includegraphics[height=11mm,
width=11mm]{sidewaylogo2020}}
\fbox{\includegraphics[
angle=60,height=11mm]
{sidewaylogo2020}}
\fbox{\includegraphics[
angle=60,totalheight=11mm]
{sidewaylogo2020}}
\fbox{\includegraphics[
height=11mm,width=11mm]{sidewaylogo2020}}
\fbox{\includegraphics[
height=11mm,width=11mm]
{sidewaylogo2020}}
\fbox{\includegraphics[
angle=-60,height=11mm]
{sidewaylogo2020}}
\fbox{\includegraphics[
angle=-60,totalheight=11mm]
{sidewaylogo2020}}
\fbox{\includegraphics[
height=11mm,width=11mm]{sidewaylogo2020}}
\frame{\includegraphics[
height=11mm,width=11mm]
{sidewaylogo2020}}
\frame{\includegraphics[
angle=-60,height=11mm]
{sidewaylogo2020}}
\frame{\includegraphics[
angle=-60,totalheight=11mm]
{sidewaylogo2020}}
\frame{\includegraphics[
height=11mm,width=11mm]{sidewaylogo2020}}
\end{document}
scale keepaspectratio Example
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{sidewaylogo2020}
\includegraphics[
scale=2]{sidewaylogo2020}
\includegraphics[height=5mm,
scale=2]{sidewaylogo2020}
\includegraphics[scale=2,
height=5mm]{sidewaylogo2020}
\includegraphics[
scale=0.5]{sidewaylogo2020}
\includegraphics[
scale=-1]{sidewaylogo2020}
\includegraphics[height=11mm]
{sidewaylogo2020}
\includegraphics[height=11mm,
width=15mm]{sidewaylogo2020}
\includegraphics[height=11mm,
width=15mm,keepaspectratio]{sidewaylogo2020}
\includegraphics[height=11mm,
width=15mm,keepaspectratio=true]{sidewaylogo2020}
\includegraphics{sidewaylogo2020}
\includegraphics[height=5mm,
width=35mm,keepaspectratio]{sidewaylogo2020}
\includegraphics[height=15mm,
width=15mm,keepaspectratio]{sidewaylogo2020}
\includegraphics[height=11mm,
width=35mm,keepaspectratio]{sidewaylogo2020}
\includegraphics[height=15mm,
width=35mm,keepaspectratio]{sidewaylogo2020}
\end{document}
origin Example
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\fbox{\includegraphics{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60]{sidewaylogo2020}}
\fbox{\includegraphics{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=l]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=lc]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=lt]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=lb]{sidewaylogo2020}}
\fbox{\includegraphics{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=r]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=rc]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=rt]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=rb]{sidewaylogo2020}}
\fbox{\includegraphics{sidewaylogo2020}}
\fbox{\includegraphics[angle=60,
origin=tc]{sidewaylogo2020}}
\fbox{\includegraphics[angle=60,
origin=bc]{sidewaylogo2020}}
\fbox{\includegraphics[angle=60,
origin=c]{sidewaylogo2020}}
\fbox{\includegraphics[angle=60,
origin=B]{sidewaylogo2020}}
\fbox{\includegraphics[angle=60
,origin=Bl]{sidewaylogo2020}}
\fbox{\includegraphics[angle=60,
origin=Br]{sidewaylogo2020}}
\fbox{\includegraphics{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=tc]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=bc]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=c]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=B]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60
,origin=Bl]{sidewaylogo2020}}
\fbox{\includegraphics[angle=-60,
origin=Br]{sidewaylogo2020}}
\end{document}
Specific Option
viewport
is used to specify a subregion of the graphic to show. The parameters of
viewport are four space separated TeX dimensions. The default dimensions are big points,
bp The parameters are taken relative to the origin specified by the bounding box.
trim
trim is used to specify the part of the graphic to not show or be cropped. The parameters of
trim are four space separated TeX dimensions.
clip
clip is used to specify the graphic will be cropped to the bounding box. Or
clip is set to
true. This is the same as using the starred form of the command
\includegraphics*
page
page is used to specify the page number of a multi-page PDF file. The default
page value is 1.
pagebox
pagebox is used to specify which bounding box to be used for PDF files. Possible values are
mediabox,
cropbox,
bleedbox, and
artbox. PDF files do not have the BoundingBox that PostScript files have, but may specify up to four predefined rectangles. The MediaBox gives the boundaries of the physical medium. The CropBox is the region to which the contents of the page are to be clipped when displayed. The BleedBox is the region to which the contents of the page should be clipped in production. The TrimBox is the intended dimensions of the finished page. The ArtBox is the extent of the page’s meaningful content. The driver will set the image size based on CropBox if present, otherwise it will not use one of the others, with a driver-defined order of preference. MediaBox is always present.
interpolate
interpolate is used to specify whether to enable or disable interpolation of raster images by the viewer. Or
interpolate is set to
true.
quiet
quiet is used to specify not to write information to the log. Or
quiet is set to
true.
draft
draft is used to specify whether the document is draft or not. Or
draft is set to
true. When
draft is
true, the graphic will not appear in the document and LaTeX will put an empty box of the correct size with the filename printed in it.
Encapsulated PostScript Option
These options address the bounding box for Encapsulated PostScript graphic files, which have a size specified with a line %%BoundingBox that appears in the file. It has four values, giving the lower x coordinate, lower y coordinate, upper x coordinate, and upper y coordinate. The units are PostScript points, equivalent to TeX’s big points, 1/72 inch. For example, if an .eps file has the line %%BoundingBox 10 20 40 80 then its natural size is 30/72 inch wide by 60/72 inch tall.
bb
bb is used to specify the bounding box of the displayed region. The parameters of
bb are four space separated TeX dimensions. Usually
\includegraphics reads the BoundingBox numbers from the EPS file automatically, so this option is only useful if the bounding box is missing from that file or if change is needed.
bbllx, bblly, bburx, bbury
These four options are obsolete, but are retained for compatibility with old packages.
bbllx,
bblly,
bburx, and
bbury are used to specify the bounding box.
natwidth, natheight
natwidth, and
natheight is used an alternative to specify
bb setting. With
bbllx=0,
bblly=0,
bburx=
natwidth,
bbury=
natheight.
hiresbb
hiresbb is used to specify using
HiResBoundingBox. Or
hiresbb is set to
true or
false. If
hiresbb is
true then LaTeX will look for %%HiResBoundingBox lines instead of %%BoundingBox lines. (The BoundingBox lines use only natural numbers while the HiResBoundingBox lines use decimals; both use units equivalent to TeX’s big points, 1/72 inch.) To override a prior setting of true, you can set it to false.
File Options
These following options allow a user to override LaTeX’s method of choosing the graphic type based on the filename extension. An example is that \includegraphics[type=png,ext=.xxx,read=.xxx]{lion} will read the file lion.xxx as though it were lion.png. For more on these, see \DeclareGraphicsRule.
type
type is used to specify the graphics type.
ext
ext is used to specify the graphics extension. Only use this in conjunction with the option
typye.
read
read is used to specify the file extension of the read file. Only use this in conjunction with the option
typye.
command
command is used to specify a command to be applied to the given file. Only use this in conjunction with the option
typye. Refering to Command line options for enabling the \write18 functionality to run external commands.