17

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}
Adam
  • 4,684

2 Answers2

12

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}
egreg
  • 1,121,712
  • Great, it boils down to \usepackage{silence} and then \WarningFilter{latex}{Command} in the preamble. Maybe not recommended to do by default ;) – Tomasz Gandor Apr 26 '20 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 '20 at 15:35
  • You can be even more specific with \WarningFilter[temp]{latex}{Command \underbar has changed.} \WarningFilter[temp]{latex}{Command \underline has changed.} – Niko Fohr Dec 01 '22 at 15:42
8

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.

cfr
  • 198,882
  • 1
    Thank you but before which packages must generally be loaded? – Adam May 23 '16 at 01:52
  • What do you mean? Sorry, but I don't understand what you're asking. – cfr May 23 '16 at 01:53
  • You said I must load it earlier. Earlier than which package? – Adam May 23 '16 at 01: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 '16 at 02:10
  • Please see edit. – cfr May 23 '16 at 02:10
  • $$\underbar$$ why doesn't it work here? is it possible to put it in math exchange somehow? – Charlie Parker Sep 27 '18 at 00:13
  • @CharlieParker What do you mean? – cfr Sep 30 '18 at 21:40
  • Why shouldn't we use \sectsy with LuaTeX? What alternatives should we use? – It'sNotALie. Oct 26 '20 at 14:19
  • I use sectsty because it is only way I could color my section headings. Is there an alternative way to adjust color of section headings that you suggest instead. I agree with general advice not to use sectsty, but cannot find alternative. – pauljohn32 Dec 08 '20 at 18:08
  • @It'sNotALie. Well, for the reasons explained in my answer? – cfr Dec 10 '20 at 05:42
  • 1
    @pauljohn32 I just redefine what I need, but lots of people like titlesec. I can't get on with it at all. Whatever I've tried to do with it has turned out to be easier without, but everyone else gets on great with it. So, if you aren't me, you might try that. – cfr Dec 10 '20 at 05:44
  • Loading the package earlier does not remove the warning for me, in Lualatex – Rastapopoulos Dec 16 '21 at 10:16