Why Are Vector Images Rasterized in XeLaTeX PDFs?
At a glance
- 1. Use a vector source
For graphicx, include a PDF figure when possible; convert SVG or EPS to PDF with a vector-capable exporter.
- 2. Compile with XeLaTeX
Include the PDF with graphicx and compile the document using xelatex.
- 3. Check the source
A PDF can contain both vector drawing and embedded bitmap images, so inspect the figure itself too.
- 4. Inspect the final PDF
Check the actual PDF, not a screenshot or low-resolution preview, for bitmap images and pixelated edges.
XeLaTeX can produce a PDF containing vector figures. If a figure looks blurry, the cause is usually the source file, a conversion or export setting, or the preview—not XeLaTeX rasterizing every included vector image.
The most reliable workflow is to include a vector PDF with graphicx. SVG and EPS need an appropriate conversion step when you use XeLaTeX; the conversion can preserve vector content, but its settings and the contents of the source matter.
What happens when XeLaTeX includes a figure
XeLaTeX produces PDF through its driver, xdvipdfmx. When graphicx includes a PDF figure, the driver normally embeds its PDF content in the document. Lines, curves, and text that are vector in the source can therefore remain vector in the output.
A PDF file is not necessarily entirely vector. It can contain bitmap images alongside vector text and paths. A plot exported to PDF, for example, may have vector axes but a rasterized data layer. Embedding that PDF preserves the mixture; it does not turn the bitmap portion back into vector artwork.
XeLaTeX’s standard graphicx workflow does not directly read SVG as a figure. Convert the SVG to PDF with a vector-capable tool, or use a workflow such as the svg package that invokes an external converter. EPS can also be converted to PDF while preserving vectors.
Include a vector PDF
Export the figure as PDF from the program that created it, then include it like this:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[ht]
\centering
\includegraphics[width=0.8\linewidth]{figure.pdf}
\caption{A vector figure included as a PDF.}
\end{figure}
\end{document}
Compile with xelatex main.tex. The graphicx package provides \includegraphics; XeLaTeX and its PDF driver handle the PDF figure. No special rasterization setting is needed.
For an SVG source, one possible conversion using Inkscape is:
inkscape figure.svg --export-filename=figure.pdf
Then include figure.pdf in the LaTeX document. Export options and SVG features can affect the result: effects that cannot be represented as PDF vectors may be rasterized during conversion. Check the converted PDF before using it. If the SVG contains a linked or embedded bitmap, that image remains bitmap content.
For EPS, use an EPS-to-PDF converter that preserves vector paths, then include the resulting PDF. Avoid converting the figure to PNG or JPEG along the way if you want it to remain resolution-independent.
Check whether the output contains raster content
Inspect the final PDF—not just a screenshot of it. A browser preview or an image exported for a website is rasterized for display, even when the PDF it came from contains vectors. Zooming in can help, but anti-aliasing in a viewer can make vector edges look soft on screen.
You can also list bitmap images in a PDF with Poppler’s pdfimages utility:
pdfimages -list main.pdf
If it reports images, the PDF contains bitmap content. That does not prove that the whole figure was rasterized: the images might be small parts of otherwise vector figures, or unrelated images elsewhere in the document. For closer inspection, open the PDF in a vector editor such as Inkscape, or use a PDF inspection tool that shows individual page objects.
If the final PDF contains a large bitmap where you expected paths, check the file you included and the settings used to export or convert it. Some graphics programs offer options such as “rasterize all” or rasterize filters; those can flatten vector artwork before LaTeX sees it.
Common mistakes
- Including a raster file by accident. A PNG or JPEG cannot become vector simply because XeLaTeX places it in a PDF. Re-export the original artwork as PDF or SVG if available.
- Assuming every PDF is vector. A PDF may be a wrapper around a full-page scan, or contain a rasterized plot. Check the source PDF itself.
- Judging by a preview. A thumbnail, screenshot, or web preview is a raster image. It does not tell you whether the source PDF is vector.
- Using an intermediate image format. Converting SVG or EPS to PNG before including it discards vector information. Convert to PDF instead when the artwork and converter support vector output.
- Overlooking conversion effects. Blur, filters, or other features may be rasterized by an SVG-to-PDF exporter. Review its output rather than assuming the file extension guarantees vector content.
If your PDF figure is vector when opened on its own but appears rasterized only after a later conversion or upload, investigate that later step: XeLaTeX’s output may not be the file being displayed or distributed.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.