2

I create a command to display some symbol in the right margins in a twoside document. The point is that they always bring an overfull hbox warning in my logs whereas it obfuscates the real overfull hboxes.

So I want these false/expected warning NOT to be reported, since there are hundreds of them as I use this command hundreds of times.

Here is the MWE

    \documentclass[10pt,, twoside, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{showframe}


\newlength{\widthtxt}
%\setlength\widthtxt{0cm}
\setlength\widthtxt{\textwidth}
\addtolength{\widthtxt}{\marginparsep}
\addtolength{\widthtxt}{\marginparwidth}
\addtolength{\widthtxt}{0.5\marginparsep}

\newcommand{\qq}{%
\marginpar[{\hspace*{\widthtxt}\makebox[0pt][c]{$\oplus$}}]{%
\hspace*{-0.5\marginparsep}%
\makebox[0pt][c]{$\oplus$}%
}
}





\begin{document}

iueriuwe
\qq


\blindtext[5]



werrewew
\qq




\end{document}
  • 1
    What exactly are you attempting with that \marginpar[{\hspace*{\widthtxt}\makebox[0pt][c]{$\oplus$}}].... why not just ask \marginpar to go on the other side if that is what you want? – daleif Jun 16 '15 at 11:02
3

Make the oversized box in a zero width box:

\newcommand{\qq}{%
  \marginpar[%
    {\makebox[0pt][l]{\hspace*{\largeurtexte}\makebox[0pt][c]{$\oplus$}}}%
  ]{%
    \hspace*{-0.5\marginparsep}%
    \makebox[0pt][c]{$\oplus$}%
  }%
}

enter image description here

Here is a simpler version of the macros (I assume that \marginparsep is wider than the \oplus symbol). Less computations, as you see.

\documentclass[10pt, twoside, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{showframe}

\newcommand{\qq}{%
  \marginpar[{% the brace for being able to use brackets
    \hfill % push the material to the right boundary of the margin par region
    \makebox[0pt][l]{% no width
      \hspace*{\marginparsep}% go to the left boundary of the text block
      \hspace*{\textwidth}% go to the right boundary of the text block
      \makebox[\marginparsep]{$\oplus$}%
    }%
  }]{%
    \hspace*{-\marginparsep}% go to the right boundary of the text block
    \makebox[\marginparsep]{$\oplus$}%
  }%
}

\begin{document}

iueriuwe\qq

\blindtext[5]

werrewew\qq

\end{document}
  • it works well indeed. My code uses \makebox[0pt] on both sides and so I already have zero width boxes for both sides of the document. So how can they bring overfull hboxes ? – Carlos Jun 16 '15 at 11:32
  • I forgot to put @egreg to contact you in the comment above – Carlos Jun 16 '15 at 17:01
  • @Carlos You had inner zero width boxes, but you had \hspace*{\widthtxt} that made the \marginpar very wide. – egreg Jun 16 '15 at 17:03

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.