A package for producing publication-quality acoustic figures (waveforms, spectrograms, and TextGrid annotations) in LaTeX, using data exported from Praat.
specTeX works in two steps:
- Praat exports a waveform image, a spectrogram image, and a TeX data file containing TikZ drawing commands (axes, labels, TextGrid interval boundaries).
- LaTeX includes the data file inside a
tikzpictureenvironment, producing a complete figure with aligned waveform, spectrogram, axis labels, and TextGrid tier annotations.
The result is a vector-quality figure suitable for journal submission, with IPA labels rendered by the Doulos SIL font.
- Praat 6.x or later
- LaTeX engine: XeLaTeX or LuaLaTeX (required by
fontspec) - IPA font: Doulos SIL (recommended; the package falls back to the default font with a warning if Doulos SIL is not installed)
- LaTeX packages:
graphicx,tikz,calc,fontspec(loaded automatically byspecTeX.sty)
specTeX.praat Praat script — run from an editor window to export figure data
specTeX.sty LaTeX style file — provides \specfigure and figure layout
LICENSE GPL v3
examples/
make_demo.praat Synthesizes "praat" and generates demo figure data (no GUI needed)
demo_document.tex LaTeX wrapper for the demo figure
example_output.tex Sample specTeX output (from the original 2013 version)
example_document.tex LaTeX wrapper for the sample output
Makefile Build targets for demo and example PDFs
- Place
specTeX.stywhere your LaTeX distribution can find it — either in your project directory or in your localtexmftree (e.g.,~/texmf/tex/latex/specTeX/). - Place
specTeX.praatwhere you can open it from Praat's script editor, or add it to the Praat menu via Praat > New Praat script.
- Open a Sound and its TextGrid together in a Praat editor window.
- Select the time range you want to display.
- Run
specTeX.praatfrom the editor's script menu. - Choose an output filename (e.g.,
myfigure.tex). - In the dialog, configure:
- Tiers: which TextGrid tiers to include (enter tier numbers concatenated, e.g.,
12for tiers 1 and 2;0for none) - Image width: figure width in inches (default: 6)
- Image height: panel height in inches (default: 1.5)
- Tiers: which TextGrid tiers to include (enter tier numbers concatenated, e.g.,
The script generates three files alongside your chosen output path:
| File | Contents |
|---|---|
myfigure.tex |
TikZ drawing commands (axes, labels, tier annotations) |
myfigure_wf.pdf |
Waveform image |
myfigure_spec.pdf |
Spectrogram image |
\documentclass{article}
\usepackage{specTeX}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\specfigure{myfigure.tex}
\end{tikzpicture}
\caption{My acoustic figure.}
\end{figure}
\end{document}Compile with xelatex or lualatex.
Override these in your document preamble with \setlength as needed:
| Length | Default | Description |
|---|---|---|
\imagewidth |
\textwidth - 3em |
Width of waveform/spectrogram images |
\imageheight |
4cm |
Height of each image panel |
\labheight |
1.5em |
Height reserved for axis labels |
\intheight |
1.5em |
Height of each TextGrid tier row |
\inttextboxsep |
1pt |
Padding around interval label text |
\dashing |
2pt |
Line width base for interval boundaries |
\dashintoimage: Set to1(default) to extend interval boundary lines down into the waveform, or0to keep them above.\ipa{text}: Renders text in Doulos SIL. Falls back to the default font if Doulos SIL is not installed.
The examples/ directory includes a self-contained demo that synthesizes the word "praat" using Praat's built-in speech synthesizer (no audio files needed):
cd examples
make demoThis runs two steps:
praat --run make_demo.praat— synthesizes "praat", extracts the phoneme and word TextGrid tiers, exports waveform and spectrogram PDFs, and generatesdemo.texxelatex demo_document.tex— compiles the final PDF with waveform, spectrogram, time/frequency/pressure axes, and two annotation tiers (phones: p, ɹ, ɑː, t; word: praat)
Other Makefile targets:
| Target | Description |
|---|---|
make demo |
Build the demo PDF (default) |
make example |
Build the example PDF (uses placeholder images) |
make clean |
Remove LaTeX auxiliary files |
make distclean |
Remove all generated files (PDFs, images, .tex data) |
GPL v3. See LICENSE.