# My Most Frequent LaTeX Problems and Fixes

I’ve spent a lot of time lately updating my mandi LaTeX package and I decided to eliminate every warning I saw when building the package. TeX and LaTeX errors and warnings are notorious for being vague so I had to do a lot of Googling to get solutions for them. Some errors and warnings have specific causes and need specific fixes but many do not. I will share the ones I encountered and for which I found fixes.

• Any warnings about font sizes or font shapes “not availble” and some kind of substitution being made: Include \usepackage{anyfontsize} in your preamble and these warnings should go away.
• Persistent underfull hbox warnings: Look for and remove any lines ending with \\ followed by a blank line. Remove the \\ (which tells LaTeX to immediately begin a new line) and find a more graceful way to handle the new line. Paragraphs should not end with \\.
• Persistent overfull hbox warnings: Look for long words LaTeX doesn’t know how to hypenate. Tell LaTeX how to hypenate such words with something like al\-ter\-ca\-tion as you type the word.
• Warnings related to labels when resetting the equation counter inside an environment like align or align*: There are two ways to fix this. One is to load the hyperref package with the hypertexnames option set to false as in \usepackage[hypertexnames=false]{hyperref}. The other is to load hyperref, then use \hypersetup{hypertexnames=false} to apply the new setting. (By the way, the hyperref package is a black box to me with seemingly infinitely any settings, none of which is adequately documented and most seem to be present only when specifically searched for. I hate it!) I found another fix for this, but it’s not intuitive and requires a different, and harder, way to reset the equation counter within the environment so I elected not to use it.
• You have requested package ‘somepackage’ but the package provides ‘somepackage’: This one took some time to solve but I think I know what’s going on and how to fix it. When I build my package, I test it from the folder where it’s built. My workflow included a shell script that copies the necessary files to their appropriate places in my local texmf tree (~/Library/texmf/ and so forth on my system). This is where LaTeX looks for document classes and packages and other associated files. Files in my local texmf tree are found before files in the master locations used by the TeXLive distribution (/use/localtexlive/2016/texmf-dist/ and so forth on my system). Apparently when you say \usepackage{somepackage} LaTeX gets confused if the package exists simultaneously in the current folder and in another folder in LaTeX’s PATH and this causes this warning when compiling. The package in the current folder always takes precedent though and is the one that gets loaded as far as I can tell. Compiling the documentation from the dtx file necessarily requires the package to be loaded, and the copy in the current folder is the version that gets loaded of course, so there’s really no good way to avoid this warning when building the package and documentation from scratch. However, before I understood what was going on, I found a fix. In the dtx file, find the \ProvidesPackage command. located between the <package> guards. This command provides not only the package’s name, but also its version and build date, which are stored in \fileversion and \filedate respectively. The fix is to comment out the line with the \ProvidesPackage command and to explicitly define a new command specifying the version and build date. In my case this was easy because my package defines a \mandiversion command containing both the version and build date in one command. So I just used \mandiversion to print the version and build date on the title page rather than letting LaTeX define them from the \ProvidesPackage command. I have no idea why, but this supresses the warning. Now that I know about the other issue I will go back to using the \ProvidesPackage command by uncommenting that line. As long as the package file isn’t in the same folder as the document I’m compiling this warning should never appear again.