2

So first off, let me show you a minimal working example:

\documentclass{amsart}

\usepackage{color}
\definecolor{mycol}{rgb}{0,0.5,0}
\newcommand\marginComment[1]{\marginpar{\hsize1.7cm\tiny\color{mycol}C: {#1}}}

\begin{document}

\marginComment{No, this really shouldn't fail!}
\end{document}

When I run this on TexMaker 4.3 I get the following error:

Badbox line 9 Underfull \hbox (badness 4636) in paragraph at lines 9--9

The weirdest part is that if I edit the words sometimes I don't get the error at all. So my assumption is that it's because of the length or something. Is there anyway to make it so that this error doesn't happen and/or a way around it if I'm making a mistake?

2

The "underfull \hbox" arises because too much stretching of the interword space on the second of three lines of the marginpar box -- between "eally" and "shouldn't" is required to achieve full justification. To remedy this situation, I suggest you include the following instruction in the preamble:

\usepackage[raggedrightboxes]{ragged2e}

This will set up raggedright typesetting (with hyphenation permitted) in all \marginpars, minipages, \parboxes, and p-columns of tabulars and arrays in your document.

The result of a full MWE (with the color changed to blue for ease of readability):

enter image description here

\documentclass{amsart}
\usepackage[raggedrightboxes]{ragged2e}
\usepackage{color}
\definecolor{mycol}{rgb}{0,0,1}
\newcommand\marginComment[1]{\marginpar{\hsize1.7cm\tiny\color{mycol}C: {#1}}}

\begin{document}
\marginComment{No, this really shouldn't fail!}
\end{document}

Addendum: If you need \RaggedRight only in \marginpars, but not in minipages, \parboxes, and p-columns of tabulars and arrays, you could (a) load the ragged2e package without the raggedrightboxes option and (b) (re)define your \marginComment macro as follows:

\newcommand\marginComment[1]{\marginpar{\RaggedRight\hsize1.7cm\tiny\color{mycol}C: {#1}}}

As a side-benefit of this method, you will no longer be bothered by cryptic "Command \@arrayparboxrestore has changed." warning messages. :-)

| improve this answer | |
  • Although that does remove the problem, I now get "Command \@arrayparboxrestore has changed." using your MWE. =/ – Aram Papazian Oct 5 '15 at 19:12
  • @AramPapazian - That's a warning message (not an error message!) you can blissfully ignore. Kudos, though, for actually looking at the output of the compilation log! – Mico Oct 5 '15 at 19:20
  • Yeah, but I don't like warnings either lol I like having a nice empty log =) (Don't most people look at compilation logs? o_O) Is the warning due to the package itself being somehow out of date or something like that? Or is there anyway around it? I did a quick google search, but I didn't see the problem anywhere. – Aram Papazian Oct 5 '15 at 19:23
  • @AramPapazian - For what it's worth, I've been using the ragged2e package for years in my own work, and I've learned to live with this message -- more specifically, to ignore it. :-) I truly have no idea why it's even being generated. – Mico Oct 5 '15 at 19:27
  • Ok, so after some more research I found the following: tex.stackexchange.com/questions/174073/… I imagine the same (or similar) thing is happening here since the document class is amsart. I switched to an article documentclass and the error went away so I assume that to be a fairly accurate assessment. So seems like, as you said, I'll just have to live with the error message =) Thanks for the information though! – Aram Papazian Oct 5 '15 at 19:33
1

If you can, use marginnote package and \marginnote instead of \marginpar.

\documentclass{amsart}

\usepackage{color}
\usepackage{marginnote}
\definecolor{mycol}{rgb}{0,0.5,0}
\newcommand\marginComment[1]{\marginnote{\hsize1.7cm\tiny\color{mycol}C: {#1}}}

\begin{document}

\marginComment{No, this really shouldn't fail!}
\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.