Skip to main content
To write a Spanish document in LaTeX with pdfLaTeX, load \usepackage[T1]{fontenc} and \usepackage[spanish]{babel}. If you want OpenType or system fonts, compile with XeLaTeX or LuaLaTeX using fontspec and polyglossia. Both setups support UTF-8 accents (á, é, í, ó, ú), the letter ñ, diaeresis (ü), inverted punctuation (¿, ¡), Spanish hyphenation, localized headings such as Resumen, and Spanish dates. With babel, the standard article class uses Índice for the table of contents.

Minimal pdfLaTeX setup

Under pdfLaTeX, keep \usepackage[T1]{fontenc} alongside [spanish]{babel} so UTF-8 words containing tildes or ñ hyphenate cleanly.
pdflatex-spanish.tex
Test this example live in your browser. Open a ready-to-compile LaTeX project with TeX Live 2026 preinstalled and zero local setup.Open starter article
When mixing Spanish and English, put the main language last: \usepackage[english,spanish]{babel} keeps Spanish active by default and lets you write inline English phrases with \foreignlanguage{english}{...}.

XeLaTeX and LuaLaTeX setup

Switch to XeLaTeX or LuaLaTeX when you need OpenType fonts or direct Unicode handling. Remove fontenc and inputenc when using fontspec and polyglossia.
xelatex-spanish.tex
If a Spanish template depends on babel-spanish options such as es-tabla, you can also load \usepackage[spanish,es-tabla]{babel} alongside fontspec under XeLaTeX or LuaLaTeX.

Useful babel-spanish options, accents, and quotes

Out of the box, babel-spanish makes several traditional typographic choices that catch technical authors by surprise—most notably labeling tables Cuadro instead of Tabla and replacing decimal dots in math mode. Pass package options to adjust them: For quotation marks, load \usepackage[autostyle=true]{csquotes} and write \enquote{...}, which produces angular quotes («…») with the default Spanish quote style.
spanish-options.tex
Type Spanish accents and punctuation directly in UTF-8 whenever possible. If you need ASCII fallback commands (for example on an English keyboard):

Common mistakes

  • Omitting \usepackage[T1]{fontenc} under pdfLaTeX: Without T1, accented words and words with ñ fail to hyphenate correctly and break when copied from the PDF.
  • Unexpected Cuadro 1 captions: By default babel-spanish labels tables Cuadro. Add es-tabla (\usepackage[spanish,es-tabla]{babel}) if your university or journal expects Tabla.
  • TikZ or arrow syntax failing under babel-spanish: Active shorthands for <, >, and " conflict with TikZ edge options and some diagram packages. Load \usetikzlibrary{babel} or pass es-noshorthands to babel.
  • Decimal point changing in equations: babel-spanish redefines . in math mode by default. Pass es-nodecimaldot if you write decimal points (3.14), or format numbers with the siunitx package.

In LaTeX Cloud Studio

LaTeX Cloud Studio compiles with TeX Live 2026 and defaults each project’s LaTeX Engine setting to Auto (Recommended). With Auto selected, LaTeX Cloud Studio starts the examples above with pdfLaTeX or XeLaTeX, as labeled. Preinstalled fonts include TeX Gyre Pagella, TeX Gyre Termes, Liberation Serif, DejaVu Serif, CMU Serif, and Noto Serif. If your document requires a custom font not in that set, upload its .ttf or .otf files to your project and load them with fontspec. Ready to write a Spanish document in the browser? Start from the Basic Article template in LaTeX Cloud Studio and replace main.tex with whichever complete example above fits your setup.