| name | latex-illustrator |
| description | Skill for seamlessly integrating images into LaTeX documents. Handles graphicx package management, figure environments, captioning, labeling, and ensuring correct relative paths for assets generated by other skills (like r-plotter). |
LaTeX Illustrator Skill
When to use this skill
ALWAYS use this skill when the user requests:
- To insert an image into a LaTeX document.
- To "orchestrate" or "integrate" visualizations generated by other tools (e.g., R, Python) into a report.
- To manage the
figures or images directory structure in a LaTeX project.
- To fix LaTeX compilation errors related to images (undefined control sequence
\includegraphics, file not found, etc.).
1. Prerequisites
Ensure the LaTeX document has the necessary packages.
Check the preamble for:
\usepackage{graphicx}
\usepackage{float} % Optional, for [H] placement
\usepackage{subcaption} % Optional, for subfigures
If missing, add them.
2. Integration Protocol
-
Locate the Image:
- Identify the path of the image to be inserted (e.g.,
images/plot.png).
- Ensure the path is relative to the main
.tex file being compiled.
-
Determine Placement:
- Inline: For simple illustrations or minimal disruption.
\begin{center}
\includegraphics[width=0.8\textwidth]{images/plot.png}
\end{center}
- Floating Figure (Recommended for formal documents):
\begin{figure}[H] % Use [h], [t], [b], or [H] (requires float package)
\centering
\includegraphics[width=0.7\textwidth]{images/plot.png}
\caption{Description of the image \label{fig:unique_label}}
\end{figure}
-
Coordination with r-plotter:
- This skill "calls"
r-plotter to generate the asset if it doesn't exist.
- Once
r-plotter confirms the file creation, latex-illustrator generates the LaTeX snippet.
-
Handling Multiple Visualizations:
- For comparing multiple plots (e.g., alternatives), use a grid of
subfigures.
- Scaling: For a 2x2 grid, use
width=0.4\textwidth for the subfigure. If the images are too large/tall, reduce to 0.3\textwidth or 0.22\textwidth per row.
- Spacing: Use
\hfill between subfigures in the same row and \vspace{1em} (or similar) between rows.
-
Verification:
- Run
pdflatex to ensure the image is found and rendered correctly.
- Check the log for
LaTeX Warning: File '...' not found.
3. Best Practices
- Relative Paths: Always use paths relative to the main
.tex file.
- Scaling for Grids:
- 2 images per row:
0.45\textwidth
- 3 images per row:
0.3\textwidth
- 4 images per row:
0.22\textwidth
- Avoid Overflows: If the
solbox or environment has padding, reduce widths by an additional 5-10%.
- Captions: Use
\caption* for unnumbered captions in solutions if preferred.
4. Example Workflow
- User: "Put the graph of x^2 in the document."
- Agent (r-plotter): Generates
images/x_squared.png.
- Agent (latex-illustrator): Inserts:
\begin{figure}[h]
\centering
\includegraphics[width=0.6\textwidth]{images/x_squared.png}
\caption{Graph of $f(x)=x^2$}
\end{figure}
- Agent: Compiles and verifies.