13

I am using the following code and I get the warning

Command \underbar has changed.

What does this mean? How do I fix it?

\documentclass{article}

\usepackage{amsmath}

\usepackage{unicode-math}

\usepackage[english,greek]{babel}

\usepackage{fontspec}

\setmainfont
[
    UprightFont = *,
    BoldFont = *Bold,
    ItalicFont = *It,
    BoldItalicFont = *BoldIt,
    Extension = .otf,
    Ligatures = TeX,
    Mapping = tex-text
]{GFSArtemisia}


\setsansfont
[
    Mapping = tex-text
]{GFSArtemisia.otf}

\setmathfont{latinmodern-math.otf}

\usepackage{sectsty}

\sectionfont{\RaggedRight}


\begin{document}

Text

\end{document}
2
  • It's caused by sectsty. You can load that earlier to avoid that particular warning.
    – cfr
    May 23, 2016 at 1:48
  • $$\underbar$$ why doesn't it work here? is it possible to put it in math exchange somehow? Sep 27, 2018 at 0:13

2 Answers 2

6

The warning is caused by a check sectsty runs on the definition of \underbar. If it doesn't match one of the definitions it expects, it warns you.

You can avoid this warning but I don't recommend it. The warning is telling you something important: that sectsty has found a definition of \underbar which is not what it expects and that things may not work properly.

In truth, I would recommend not using sectsty with LuaTeX/XeTeX. In particular, I wouldn't use it with unicode-math.

If you insist, for LuaTeX, you can avoid that particular warning by loading the package earlier. For XeTeX, you can avoid that warning by loading the package earlier.

For example,

\documentclass{article}
\usepackage{sectsty}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage[english,greek]{babel}
\usepackage{fontspec}
\setmainfont
[
    UprightFont = *,
    BoldFont = *Bold,
    ItalicFont = *It,
    BoldItalicFont = *BoldIt,
    Extension = .otf,
    Ligatures = TeX,
]{GFSArtemisia}
\setsansfont
[
    Ligatures = TeX,
]{GFSArtemisia.otf}
\setmathfont{latinmodern-math.otf}
\sectionfont{\RaggedRight}
\begin{document}

Text

\end{document}

However, I get other warnings with LuaTeX.

12
  • Thank you but before which packages must generally be loaded?
    – Adam
    May 23, 2016 at 1:52
  • What do you mean? Sorry, but I don't understand what you're asking.
    – cfr
    May 23, 2016 at 1:53
  • You said I must load it earlier. Earlier than which package?
    – Adam
    May 23, 2016 at 1:54
  • I'm not sure. It doesn't know about the new font handling stuff. Probably when to load it depends on the result you want. That is, how do you want the definition of \underbar to end up at the end of the preamble? If you load it after unicode-math, you'll get a warning because unicode-math redefines \underbar. But the real question is: do you want sectsty's or unicode-math's or something else?
    – cfr
    May 23, 2016 at 2:10
  • Please see edit.
    – cfr
    May 23, 2016 at 2:10
8

You have really nothing to worry about, provided you don't use sectsty for underlining section titles.

The package does a check on \underbar and on \underline, because it wants to redefine them but it just does so when typesetting those titles.

So, if you don't use underlining (and you're better not to), there should be no problem.

Something actually can be done to fully disable those redefinitions (only risky if you happen to use \underbar in a section title, actually).

\documentclass{article}

\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage[english,greek]{babel}
\usepackage[immediate]{silence}
\WarningFilter[temp]{latex}{Command} % silence the warning
\usepackage{sectsty}
\DeactivateWarningFilters[temp] % So nothing unrelated gets silenced

\makeatletter % disable the runtime redefinitions
\let\SS@makeulinesect\relax
\let\SS@makeulinepartchap\relax
\makeatother

\setmainfont[
    UprightFont = *,
    BoldFont = *Bold,
    ItalicFont = *It,
    BoldItalicFont = *BoldIt,
    Extension = .otf,
    Ligatures = TeX,
]{GFSArtemisia}
\setsansfont{GFSArtemisia.otf}
\setmathfont{latinmodern-math.otf}

\sectionfont{\RaggedRight}


\begin{document}

Text

\end{document}
2
  • Great, it boils down to \usepackage{silence} and then \WarningFilter{latex}{Command} in the preamble. Maybe not recommended to do by default ;) Apr 26, 2020 at 15:33
  • 3
    @TomaszGandor Until the package author/maintainer decides to update it, one has to live with the warning (or silence it).
    – egreg
    Apr 26, 2020 at 15:35

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.