CTAN Comprehensive TeX Archive Network

Directory macros/latex/contrib/mathwrap

README.md

mathwrap

A package to improve line-breaking in inline math mode

Lee Yiu Sing November 2026 — Version 1.0

Introduction

By default, strongly avoids breaking lines inside inline math ($...$), frequently resulting in "Overfull \hbox" warnings for long lists or sequences. The mathwrap package modifies the math-mode comma and adjusts penalty parameters to allow breaks where appropriate, without affecting display math environments.

Installation

Place mathwrap.sty in your project directory or local texmf tree.

Usage

Load the package in your preamble:

\usepackage{mathwrap}

Package Options

By default, mathwrap lowers \binoppenalty and \relpenalty, and increases \emergencystretch. You can disable these global changes if they conflict with your document class:

  • nopenalties: Disables adjustments to \binoppenalty and \relpenalty.
  • nostretch: Disables adjustments to \emergencystretch.

Example:

\usepackage[nopenalties,nostretch]{mathwrap}

Commands

Activating the comma can occasionally conflict with parser-reliant packages (e.g., TikZ, pgfplots, siunitx). You can toggle the package behavior locally to resolve compilation errors inside specific environments:

  • \mathwrapOff : Restores the standard math comma.
  • \mathwrapOn : Reactivates the mathwrap comma.

Example workaround for TikZ:

\mathwrapOff
\begin{tikzpicture}
  \draw (0,0) -- (1,1);
\end{tikzpicture}
\mathwrapOn

License

This package is released under the Project Public License (LPPL), version 1.3c or later.

Download the contents of this package in one zip archive (163.6k).

Mathwrap – Automatic line breaking in inline math

mathwrap improves line breaking in inline math mode. By default, avoids breaking lines inside inline math, which frequently results in Overfull \hbox warnings for long lists or sequences. The package makes the comma active in inline math to allow breaks after it, and optionally adjusts the penalties for binary operators and relations as well as \emergencystretch. Display math is not affected.

PackageMathwrap
Version1.0
LicensesThe Project Public License 1.3c
Copyright2026 Lee Yiu Sing
MaintainerYiu Sing Lee
Contained inTeX Live as mathwrap
TopicsMaths
...
Guest Book Sitemap Contact Contact Author