MacroTeX Usage Guide
MacroTeX is a VSCode extension that helps with inserting macros in LaTeX documents.
Table of contents
Features
- Macro completion for image paths
- Image preview on hover
- Bulk image insertion from explorer
- Configurable LaTeX macros
- Smart multi-document support:
- Automatic detection of main LaTeX files
- Intelligent path resolution based on document hierarchy
- File system tracking:
- Automatic path updates when files are moved or renamed
- Smart commenting of references to deleted files
- Enhanced path suggestions:
- Prioritized local files in suggestions
- Intelligent path completion based on context
- Support for various file extensions in path suggestions
Getting Started
- Install the MacroTeX extension from the VSCode marketplace
- Open your LaTeX project in VSCode
- The extension will automatically detect all main LaTeX files in your workspace
- Start using macros in any .tex file - paths will be automatically resolved to the nearest main file
Using MacroTeX
Auto-completion
- Start typing a LaTeX macro (e.g.
\fg ) in your .tex file
- The extension will show available paths that match the macro's file types requirements
- Select a path to automatically insert the complete macro with proper paths
Extension creates snippets from user defined macros.
Image Preview
- Hover over an image path in your LaTeX document
- A preview of the image will be displayed in a hover tooltip
Bulk Image Insertion
- In the VSCode explorer, select one or multiple images/folders
- Right-click and select "Insert in active document"
- Choose the macro you want to use
- The extension will:
- Insert the selected images using the chosen macro
- Create proper relative paths
- Generate identifiers based on folder/file names
- Optionally insert
\clearpage after every 2 images
Example usage:

Configuration
Configure macros in VSCode settings. Example minimal setup:
"latexMacros.macrosList": [
{
"signature": "\\fg{PATH}{}{}",
"extensions": ["png", "jpg"]
}
]
Path Management
- Automatic detection and handling of multiple main LaTeX files
- Smart relative path generation based on document hierarchy
- Automatic path updates when files are moved or renamed
- Intelligent handling of deleted files
- Support for nested directory structures
Custom Macros
When creating custom macros, understand these placeholders:
{PATH} : Required for path autocompletion
{Caption} : Optional, for image captions
{Identifier} : Optional, for reference labels
Example configuration:
{
"signature": "\\fg[width]{PATH}{Caption}{Identifier}",
"extensions": ["png", "jpg"]
}
Corresponding LaTeX macro:
\newcommand*{\fg}[4][\textwidth]{
\begin{figure}[!htb]
\begin{center}
\includegraphics[width=#1]{#2}
\caption{#3}
\label{rys:#4}
\end{center}
\end{figure}
}
Troubleshooting
Common Issues
- Macro not appearing in suggestions
- Check if file extension is supported
- Verify macro configuration in settings
- Ensure there is a main LaTeX file in your workspace
- Image preview not working
- Ensure image path is correct
- Check if image format is supported
- Verify the path relative to the main LaTeX file
- Path resolution issues
- Check if your document is in the same workspace as the main LaTeX file
- Verify that the file contains a \documentclass declaration
Support
- Report issues on GitHub repository
- Check documentation for updates
- Join community discussions
| |