\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\geometry{a4paper, margin=1.2in}
\usepackage[colorlinks=true, linkcolor=blue, urlcolor=blue]{hyperref}

\title{\textsf{mathwrap}\\ 
\large A LaTeX package to improve line-breaking in inline math mode}
\author{Lee Yiu Sing}
\date{November 2026 \quad Version 1.0}

\begin{document}

\maketitle

\section{Introduction}

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

\section{Installation}

Place \texttt{mathwrap.sty} in your project directory or local \texttt{texmf} tree.

\section{Usage}

Load the package in your preamble:
\begin{verbatim}
\usepackage{mathwrap}
\end{verbatim}

\subsection{Package Options}

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

\begin{itemize}
    \item \texttt{nopenalties}: Disables adjustments to \verb|\binoppenalty| and \verb|\relpenalty|.
    \item \texttt{nostretch}: Disables adjustments to \verb|\emergencystretch|.
\end{itemize}

\noindent Example:
\begin{verbatim}
\usepackage[nopenalties,nostretch]{mathwrap}
\end{verbatim}

\subsection{Commands}

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

\begin{itemize}
    \item \verb|\mathwrapOff| : Restores the standard math comma.
    \item \verb|\mathwrapOn| : Reactivates the \textsf{mathwrap} comma.
\end{itemize}
\noindent 
Example workaround for \textsf{TikZ}:
\begin{verbatim}
\mathwrapOff
\begin{tikzpicture}
  \draw (0,0) -- (1,1);
\end{tikzpicture}
\mathwrapOn
\end{verbatim}

\section{License}

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

\end{document}