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
- Table Generator Sidebar:
- Visual creation of LaTeX tables
- Direct insertion into documents
- CSV to LaTeX Table Conversion:
- Convert CSV files directly to LaTeX tables
- Automatic insertion into your document
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:

- Open the sidebar by clicking on the MacroTeX icon in the activity bar
- Use the Table Generator panel to:
- Set the number of rows and columns
- Preview the table structure
- Click "Convert to LaTeX" to add the LaTeX table code to your active document
- The table will be inserted at the current cursor position with proper LaTeX formatting
CSV to LaTeX Table Conversion
- Select a CSV file in the VSCode explorer
- Right-click and select "Insert CSV as table"
- The extension will:
- Convert the CSV data to a properly formatted LaTeX table
- Insert the table at the current cursor position in the active editor
- Maintain the structure and data from your CSV file
Use this feature to quickly import data tables from CSV files into your LaTeX documents without manual formatting.
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