0

I wanted to make a horizontal separator in LaTeX

So i used this piece of code(as described here):

\noindent\mathmakebox[\linewidth]{\rule{\paperwidth}{0.4pt}}

The strange thing that it's properly displaying after compiling it to the PDF but in compile time it is arguing.

I am using Visual Studio Code and MikTeX

  • 3
    Welcome to TeX.SE. What do you mean with 'arguing'? Do you get an error or warning? If yes, what is the exact message? – Marijn Nov 20 '22 at 15:01
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 20 '22 at 15:11
  • 1
    The command \mathmakebox is provided by mathtools and can only be used in math formulas, not in plain text. – egreg Nov 20 '22 at 15:20
  • 1
    if asking about an error message always show the exact message, copied from the log file – David Carlisle Nov 20 '22 at 16:08

1 Answers1

1

The code in the quoted answer has \makebox, not \mathmakebox, which is a command that can only be used in math mode (and requires mathtools).

They're not interchangeable. You get two error messages about missing $ inserted, one when \mathmakebox is not encountered in math mode and one when closing the box.

Note that \makebox can be used in math mode, but its contents is typeset in text mode, so the commands have very different purposes.

However, you should use

\noindent\makebox[\columnwidth]{\rule{2\paperwidth}{0.4pt}}

or \maxdimen instead of 2\paperwidth as I showed in the answer I added in that old thread.

egreg
  • 1,121,712