graphicx

LaTeX graphicx package for image inclusion and manipulation. Use when helping users insert images, resize graphics, create figure environments, or work with subfigures.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "graphicx" with this command: npx skills add igbuend/grimbard/igbuend-grimbard-graphicx

graphicx — Image Inclusion & Manipulation

CTAN: https://ctan.org/pkg/graphicx
Manual: texdoc graphicx

Setup

\usepackage{graphicx}

% Set default search paths for images
\graphicspath{{images/}{figures/}{./}}

\includegraphics Options

\includegraphics[options]{filename}
OptionExampleDescription
widthwidth=0.8\textwidthScale to width
heightheight=5cmScale to height
scalescale=0.5Scale factor
angleangle=90Rotate (counterclockwise, degrees)
trimtrim=1cm 2cm 1cm 0cmCrop: left bottom right top
clipclipMust accompany trim to actually crop
pagepage=3Page of multi-page PDF
keepaspectratiokeepaspectratioMaintain ratio when both width+height set
draftdraftShow filename box instead of image
bbbb=0 0 100 100Bounding box (EPS)
viewportviewport=50 50 200 200View sub-region (with clip)
resolutionresolution=300DPI for bitmap without natural size
% Common patterns
\includegraphics[width=\textwidth]{photo}
\includegraphics[width=0.48\textwidth]{fig1}
\includegraphics[height=4cm, keepaspectratio]{diagram}
\includegraphics[angle=90, width=0.5\textwidth]{landscape}
\includegraphics[trim=10mm 5mm 10mm 5mm, clip, width=\linewidth]{screenshot}
\includegraphics[page=2, width=\textwidth]{multipage.pdf}

Supported Formats by Engine

EngineVectorRaster
pdfLaTeXPDF, EPS (auto-converted)PNG, JPG
XeLaTeXPDF, EPSPNG, JPG, BMP
LuaLaTeXPDF, EPSPNG, JPG
LaTeX→DVIEPS(none natively)

Best practice: Use PDF for vector graphics, PNG for screenshots/diagrams with transparency, JPG for photos.

Scaling & Rotating Commands

% Scale content (text or images)
\scalebox{2}{Doubled}
\scalebox{0.5}[1.5]{Stretched}  % [horizontal]{vertical}

% Resize to exact dimensions
\resizebox{3cm}{!}{Content}     % ! = keep aspect ratio
\resizebox{!}{2cm}{Content}
\resizebox{3cm}{2cm}{Content}   % exact (may distort)

% Rotate
\rotatebox{45}{Rotated text}
\rotatebox[origin=c]{90}{Centered rotation}
% origin: l, r, c, t, b, lt, rb, etc.

Figure Environment

\begin{figure}[htbp]   % placement: here, top, bottom, page
  \centering
  \includegraphics[width=0.8\textwidth]{plot.pdf}
  \caption{Experimental results showing growth over time.}
  \label{fig:results}
\end{figure}

% Reference: See Figure~\ref{fig:results}.

Placement Specifiers

SpecMeaning
hHere (approximately)
tTop of page
bBottom of page
pSeparate float page
!Override internal limits
HExactly here (requires float package)

Tip: Use [htbp] as default. Avoid [H] unless necessary.

Subfigures

\usepackage{subcaption}  % preferred over subfig/subfigure

\begin{figure}[htbp]
  \centering
  \begin{subfigure}[b]{0.48\textwidth}
    \centering
    \includegraphics[width=\textwidth]{fig_a.pdf}
    \caption{First result}
    \label{fig:sub_a}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{0.48\textwidth}
    \centering
    \includegraphics[width=\textwidth]{fig_b.pdf}
    \caption{Second result}
    \label{fig:sub_b}
  \end{subfigure}
  \caption{Comparison of results. (a) shows X, (b) shows Y.}
  \label{fig:comparison}
\end{figure}

Three Subfigures in a Row

\begin{figure}[htbp]
  \centering
  \begin{subfigure}[b]{0.32\textwidth}
    \centering
    \includegraphics[width=\textwidth]{a}
    \caption{A}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{0.32\textwidth}
    \centering
    \includegraphics[width=\textwidth]{b}
    \caption{B}
  \end{subfigure}
  \hfill
  \begin{subfigure}[b]{0.32\textwidth}
    \centering
    \includegraphics[width=\textwidth]{c}
    \caption{C}
  \end{subfigure}
  \caption{Three results side by side.}
\end{figure}

Overlays with overpic

\usepackage{overpic}

\begin{overpic}[width=0.8\textwidth, grid, tics=10]{photo.jpg}
  % Coordinates are percentages (0-100)
  \put(20,80){\color{red}\Large\textbf{Label A}}
  \put(70,30){\vector(-1,1){15}}
\end{overpic}

Remove grid, tics=10 after positioning. Coordinates are percentage-based.

Wrapfigure (Text Wrapping)

\usepackage{wrapfig}

\begin{wrapfigure}{r}{0.4\textwidth}  % r=right, l=left
  \centering
  \includegraphics[width=0.38\textwidth]{small_fig}
  \caption{Side figure.}
\end{wrapfigure}
Text flows around the figure here...

Common Pitfalls

ProblemCauseFix
"File not found"Wrong path or extensionCheck \graphicspath, omit extension
"Unknown graphics extension .eps"pdfLaTeX can't use raw EPSUse epstopdf package (auto-converts) or switch to PDF
Blurry imagesLow resolution rasterUse ≥300 DPI or vector format
Figure floats awayLaTeX float algorithmUse [htbp!], add \FloatBarrier (placeins pkg)
Overfull hbox with subfiguresWidths sum > \textwidthEnsure widths + gaps < 1.0\textwidth
trim not croppingMissing clipAlways pair trim with clip
Image upside downCamera EXIF rotationPre-rotate or use angle=180
Subfigure numbering wrongUsing deprecated subfigure pkgSwitch to subcaption

Tips

  • Omit file extensions — LaTeX picks the best format automatically
  • Use \linewidth inside minipages/columns, \textwidth at top level
  • For publication: vector (PDF/EPS) for plots, high-DPI PNG/JPG for photos
  • \DeclareGraphicsExtensions{.pdf,.png,.jpg} to set search priority
  • draft option on \documentclass replaces all images with boxes (faster compilation)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

tikz

No summary provided by upstream source.

Repository SourceNeeds Review
General

latex

No summary provided by upstream source.

Repository SourceNeeds Review
General

pgfplots

No summary provided by upstream source.

Repository SourceNeeds Review
General

biblatex

No summary provided by upstream source.

Repository SourceNeeds Review