A beginner-friendly tutorial for setting up LaTeX environment and generating PDF documents using modern AI-powered IDEs.
- Overview
- Step 1: Install LaTeX Distribution
- Step 2: Install IDE with LaTeX Support
- Step 3: Configure IDE
- Step 4: Create Your First LaTeX Document
- Step 5: Generate PDF
- Using AI to Write LaTeX
- System Prompts for AI Assistants
- Troubleshooting
- Resources
This guide will help you set up a complete LaTeX environment from scratch. By the end, you will be able to:
- Write LaTeX code in a modern IDE
- Use AI assistants to generate LaTeX code
- Compile LaTeX to PDF with one click
| Component | Purpose | Options |
|---|---|---|
| LaTeX Distribution | Compiles .tex to .pdf | MiKTeX (Windows), TeX Live (All platforms) |
| IDE | Write and edit LaTeX | Kiro, VS Code, Cursor, Windsurf |
| AI Assistant | Generate LaTeX code | Claude, GPT, Copilot |
Choose ONE of the following options based on your operating system.
Download: https://miktex.org/download
- Download the MiKTeX installer for Windows
- Run the installer
- Select "Install missing packages on-the-fly: Yes"
- Complete the installation
Verify installation:
pdflatex --versionExpected output:
MiKTeX-pdfTeX 4.x.x (MiKTeX 24.x)
Windows:
Download from https://tug.org/texlive/acquire-netinstall.html
macOS:
brew install --cask mactexLinux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install texlive-fullLinux (Fedora):
sudo dnf install texlive-scheme-fullChoose ONE of the following IDEs.
- Download from https://kiro.dev/
- Install and open Kiro
- Kiro has built-in AI assistance for LaTeX
- Download from https://code.visualstudio.com/
- Install the following extensions:
- LaTeX Workshop (James Yu) - Essential for LaTeX compilation
- GitHub Copilot (Optional) - AI code assistance
Install LaTeX Workshop:
- Open VS Code
- Press
Ctrl+Shift+Xto open Extensions - Search "LaTeX Workshop"
- Click Install
- Download from https://cursor.sh/
- Install and open Cursor
- Cursor has built-in AI (Claude/GPT) for code generation
- Install LaTeX Workshop extension (same as VS Code)
- Download from https://codeium.com/windsurf
- Install and open Windsurf
- Install LaTeX Workshop extension
After installing LaTeX Workshop, the default settings work for most cases. Optional configuration:
- Open Settings (
Ctrl+,) - Search "latex-workshop"
- Recommended settings:
{
"latex-workshop.latex.autoBuild.run": "onSave",
"latex-workshop.latex.recipes": [
{
"name": "pdflatex",
"tools": ["pdflatex"]
}
],
"latex-workshop.view.pdf.viewer": "tab"
}Kiro works out of the box with LaTeX. No additional configuration needed.
- Open your IDE
- Create a new file named
document.tex - Copy the following basic template:
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{margin=2.5cm}
\title{My First LaTeX Document}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
This is my first LaTeX document. LaTeX is a powerful typesetting system used for creating professional documents.
\section{Mathematics}
LaTeX excels at mathematical notation:
\begin{equation}
E = mc^2
\end{equation}
The quadratic formula:
\begin{equation}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\end{equation}
\section{Lists}
\subsection{Bullet Points}
\begin{itemize}
\item First item
\item Second item
\item Third item
\end{itemize}
\subsection{Numbered List}
\begin{enumerate}
\item Step one
\item Step two
\item Step three
\end{enumerate}
\section{Conclusion}
LaTeX makes document creation easy and professional.
\end{document}VS Code / Cursor / Windsurf with LaTeX Workshop:
- Option A: Save the file (
Ctrl+S) - Auto-compiles if enabled - Option B: Press
Ctrl+Alt+Bto build - Option C: Click the green play button in the top-right corner
The PDF will appear in a new tab or in the same folder as your .tex file.
Kiro:
- Use the built-in compile command or terminal
# Navigate to your file location
cd C:\path\to\your\file
# Compile
pdflatex document.tex- Press
Ctrl+Shift+P - Type "LaTeX Workshop: Build LaTeX project"
- Press Enter
Modern IDEs with AI can generate LaTeX code from natural language.
Simply describe what you want in a comment or chat:
Example prompts:
Create a LaTeX table with 3 columns: Name, Age, City with 5 rows of sample data
Write LaTeX code for a professional CV with sections for education, experience, and skills
Generate a LaTeX Beamer presentation with 5 slides about machine learning
- Be specific about the document type (article, report, beamer)
- Mention required packages if known
- Describe the structure you want
- Ask for compilable, complete code
Use these prompts to get better LaTeX output from AI assistants.
You are a LaTeX expert. When I ask for LaTeX code:
1. Provide complete, compilable code including documentclass and preamble
2. Use standard packages that work with pdflatex
3. Include necessary usepackage declarations
4. Add comments explaining complex parts
5. Ensure the code compiles without errors
You are a professional CV/Resume LaTeX generator. Create ATS-friendly CVs with:
1. Clean, readable formatting
2. Standard fonts (no special font packages)
3. Sections: Contact, Summary, Experience, Education, Skills
4. Proper spacing and alignment
5. Complete compilable code
You are a mathematical LaTeX specialist. When creating math documents:
1. Use amsmath, amssymb packages
2. Proper equation numbering with equation environment
3. Aligned equations with align environment
4. Clear formatting for theorems and proofs
5. Include all necessary packages in preamble
You are an academic paper LaTeX specialist. Create papers with:
1. Proper document structure (abstract, sections, references)
2. Figure and table environments with captions
3. Bibliography setup with BibTeX
4. Cross-references using label and ref
5. Standard academic formatting
You are a LaTeX Beamer specialist. Create presentations with:
1. Professional theme (Madrid, Berlin, or Singapore)
2. Clear frame titles
3. Bullet points and numbered lists
4. Support for images and tables
5. Proper frame breaks for long content
Cause: LaTeX not in system PATH
Solution:
# Find MiKTeX installation
where.exe pdflatex
# If not found, add to PATH manually or reinstall MiKTeX with "Add to PATH" optionCause: Missing font packages
Solution:
- MiKTeX will auto-install missing packages (click Yes when prompted)
- Or remove custom font packages and use defaults:
% Remove these lines if causing issues
% \usepackage{fontawesome5}
% \usepackage{custom-font}Cause: Missing LaTeX package
Solution (MiKTeX):
- Open MiKTeX Console
- Go to Packages
- Search and install the missing package
Solution (TeX Live):
tlmgr install package-nameCause: Compilation error in LaTeX code
Solution:
- Check the output/terminal for error messages
- Look for the line number mentioned in the error
- Common fixes:
- Missing
\end{}for an environment - Unescaped special characters (
%,&,$,#,_) - Missing closing braces
}
- Missing
Solution: Add encoding packages:
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}- LaTeX Project
- Overleaf Learn - Excellent tutorials
- MiKTeX Documentation
- LaTeX Cheat Sheet
- Detexify - Draw a symbol, get LaTeX code
- Tables Generator - Visual table creator
This repository includes example files:
| File | Description |
|---|---|
main.tex |
Basic document template |
overview.tex |
Document with sections |
cv_hieu.tex |
Professional CV example |
📁 Check the prompts/ folder for detailed AI prompts:
| Prompt File | Purpose |
|---|---|
01-latex-expert.md |
General LaTeX expert prompt |
02-cv-resume-generator.md |
Professional CV/Resume generation |
03-mathematical-document.md |
Math equations, theorems, proofs |
04-academic-paper.md |
IEEE/ACM conference papers |
05-beamer-presentation.md |
Presentation slides |
06-table-generator.md |
Professional tables with booktabs |
07-tikz-diagrams.md |
TikZ diagrams, flowcharts, neural networks |
08-error-fixer.md |
Debug LaTeX compilation errors |
09-image-to-latex.md |
Convert formula images to LaTeX |
10-document-converter.md |
Convert Word/PDF to LaTeX |
11-bibliography-citations.md |
BibTeX, citations, references |
12-algorithm-pseudocode.md |
Algorithm and pseudocode formatting |
Usage: Copy the system prompt from any file and paste it into your AI assistant (Claude, GPT, Copilot) to get specialized LaTeX help.
This project is licensed under the MIT License.
Nghi Danh Hoang Hieu
- AWS Community Builder
- AI Platform Engineer
If you found this guide helpful, please give it a star on GitHub.