Skip to content

LaTeX Tutorial: Generate Professional Documents with AI Assistants - Setup MiKTeX, VS Code, Cursor with Prompts Library for CV, Papers, Diagrams, and More

Notifications You must be signed in to change notification settings

ihatesea69/latex-to-code-ai-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

LaTeX to Code - Setup and Usage Guide

License: MIT AWS Community Builder

A beginner-friendly tutorial for setting up LaTeX environment and generating PDF documents using modern AI-powered IDEs.

Table of Contents

Overview

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

What You Need

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

Step 1: Install LaTeX Distribution

Choose ONE of the following options based on your operating system.

Option A: MiKTeX (Recommended for Windows)

Download: https://miktex.org/download

  1. Download the MiKTeX installer for Windows
  2. Run the installer
  3. Select "Install missing packages on-the-fly: Yes"
  4. Complete the installation

Verify installation:

pdflatex --version

Expected output:

MiKTeX-pdfTeX 4.x.x (MiKTeX 24.x)

Option B: TeX Live (All Platforms)

Windows:

Download from https://tug.org/texlive/acquire-netinstall.html

macOS:

brew install --cask mactex

Linux (Ubuntu/Debian):

sudo apt-get update
sudo apt-get install texlive-full

Linux (Fedora):

sudo dnf install texlive-scheme-full

Step 2: Install IDE with LaTeX Support

Choose ONE of the following IDEs.

Option A: Kiro IDE

  1. Download from https://kiro.dev/
  2. Install and open Kiro
  3. Kiro has built-in AI assistance for LaTeX

Option B: VS Code

  1. Download from https://code.visualstudio.com/
  2. Install the following extensions:
    • LaTeX Workshop (James Yu) - Essential for LaTeX compilation
    • GitHub Copilot (Optional) - AI code assistance

Install LaTeX Workshop:

  1. Open VS Code
  2. Press Ctrl+Shift+X to open Extensions
  3. Search "LaTeX Workshop"
  4. Click Install

Option C: Cursor

  1. Download from https://cursor.sh/
  2. Install and open Cursor
  3. Cursor has built-in AI (Claude/GPT) for code generation
  4. Install LaTeX Workshop extension (same as VS Code)

Option D: Windsurf

  1. Download from https://codeium.com/windsurf
  2. Install and open Windsurf
  3. Install LaTeX Workshop extension

Step 3: Configure IDE

VS Code / Cursor / Windsurf Configuration

After installing LaTeX Workshop, the default settings work for most cases. Optional configuration:

  1. Open Settings (Ctrl+,)
  2. Search "latex-workshop"
  3. Recommended settings:
{
    "latex-workshop.latex.autoBuild.run": "onSave",
    "latex-workshop.latex.recipes": [
        {
            "name": "pdflatex",
            "tools": ["pdflatex"]
        }
    ],
    "latex-workshop.view.pdf.viewer": "tab"
}

Kiro Configuration

Kiro works out of the box with LaTeX. No additional configuration needed.

Step 4: Create Your First LaTeX Document

Create a New File

  1. Open your IDE
  2. Create a new file named document.tex
  3. 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}

Step 5: Generate PDF

Method 1: Using IDE (Recommended)

VS Code / Cursor / Windsurf with LaTeX Workshop:

  • Option A: Save the file (Ctrl+S) - Auto-compiles if enabled
  • Option B: Press Ctrl+Alt+B to 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

Method 2: Using Terminal

# Navigate to your file location
cd C:\path\to\your\file

# Compile
pdflatex document.tex

Method 3: Using Command Palette

  1. Press Ctrl+Shift+P
  2. Type "LaTeX Workshop: Build LaTeX project"
  3. Press Enter

Using AI to Write LaTeX

Modern IDEs with AI can generate LaTeX code from natural language.

In Kiro / Cursor / VS Code with Copilot

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

Tips for AI-Assisted LaTeX

  1. Be specific about the document type (article, report, beamer)
  2. Mention required packages if known
  3. Describe the structure you want
  4. Ask for compilable, complete code

System Prompts for AI Assistants

Use these prompts to get better LaTeX output from AI assistants.

General LaTeX Expert Prompt

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

CV/Resume Prompt

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

Mathematical Document Prompt

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

Academic Paper Prompt

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

Beamer Presentation Prompt

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

Troubleshooting

Problem: "pdflatex is not recognized"

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" option

Problem: "Font not found" error

Cause: Missing font packages

Solution:

  1. MiKTeX will auto-install missing packages (click Yes when prompted)
  2. Or remove custom font packages and use defaults:
% Remove these lines if causing issues
% \usepackage{fontawesome5}
% \usepackage{custom-font}

Problem: "Package not found"

Cause: Missing LaTeX package

Solution (MiKTeX):

  1. Open MiKTeX Console
  2. Go to Packages
  3. Search and install the missing package

Solution (TeX Live):

tlmgr install package-name

Problem: PDF not generating

Cause: Compilation error in LaTeX code

Solution:

  1. Check the output/terminal for error messages
  2. Look for the line number mentioned in the error
  3. Common fixes:
    • Missing \end{} for an environment
    • Unescaped special characters (%, &, $, #, _)
    • Missing closing braces }

Problem: Special characters not displaying

Solution: Add encoding packages:

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

Resources

Official Documentation

Quick References

Online Editors (No Installation Required)

  • Overleaf - Full-featured online LaTeX editor
  • Papeeria - Simple online LaTeX editor

Example Files

This repository includes example files:

File Description
main.tex Basic document template
overview.tex Document with sections
cv_hieu.tex Professional CV example

AI Prompts Library

📁 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.

License

This project is licensed under the MIT License.

Author

Nghi Danh Hoang Hieu

  • AWS Community Builder
  • AI Platform Engineer

If you found this guide helpful, please give it a star on GitHub.

About

LaTeX Tutorial: Generate Professional Documents with AI Assistants - Setup MiKTeX, VS Code, Cursor with Prompts Library for CV, Papers, Diagrams, and More

Topics

Resources

Stars

Watchers

Forks