2

I am importing minted like this:

\documentclass[english,12pt,a4paper,twoside,chapter=TITLE,section=TITLE,]{abntex2}
\usepackage[newfloat,chapter,outputdir=setup/cache]{minted}

\begin{document}
Hi.
\end{document}

And when running it:

[no file]:77: Package minted Warning: Unexpected value for option `chapter'(minted) is ignored on input line 77.
[no file]:77: Package minted Warning: Unexpected value for option `section'(minted) is ignored on input line 77.

This warning is coming from the package kvoptions.sty:

File: latex/oberdiek/kvoptions.sty
409:     {#1}{%
410:       Unexpected value for option `#3'\MessageBreak
411:       is ignored%
412:     }%
413:   \fi

As you see, my document class abntex2 takes in the options chapter and section, which minted is trying to process for himself.

How can I fix this warning? (I mean, get rid of it, (it is the last one on my thesis))

Related:

  1. Warning when adding package minted?
  2. How negate value of Boolean option in package using kvoptions
user
  • 4,745

2 Answers2

4

The top line defines chapter=TITLE as a global option, which so is passed to every loaded package.

Since minted has chapter declared with \DeclareVoidOption, kvoptions warns about it having a value, at the moment the option is passed to the package, which happens before the explicit options are evaluated. The warning about chapter is innocuous, but the one about section isn't, because minted thinks that you have passed the section option, which is not what you want.

The only workaround I see is to remove the offending options from the list of global options before loading minted.

\documentclass[english,12pt,a4paper,twoside,chapter=TITLE,section=TITLE,]{abntex2}

\makeatletter
\begingroup
\def\x#1chapter=TITLE,#2\@nil{%
  \endgroup\def\@classoptionslist{#1#2}%
}\expandafter\x\@classoptionslist\@nil
\begingroup
\def\x#1section=TITLE,#2\@nil{%
  \endgroup\def\@classoptionslist{#1#2}%
}\expandafter\x\@classoptionslist\@nil
\makeatother

\usepackage[newfloat,chapter,outputdir=setup/cache]{minted}

\begin{document}
Hi.
\end{document}
egreg
  • 1,121,712
  • If I load \usepackage{datetime} before you using your fix, i.e., right after documentclass, latex throw this error: Runaway argument? english,12pt,a4paper,twoside,\@nil \begingroup \def \x ##1section=TIT\ETC. test2.tex:16: Paragraph ended before \x was complete – user Nov 03 '19 at 18:59
  • If I removed the fix, then, the two warnings keep popping up. Instead, I kept your fix, while I imported the datetime package after including the minted package, and the error was gone. – user Nov 03 '19 at 19:15
  • @user I guess this has to do with the fact that datetime loads xkeyval, which plays with \@classoptions. So yes, the fix should be before loading datetime. – egreg Nov 03 '19 at 20:52
  • When I do not add the arguments chapter=TITLE,section=TITLE to my class, your code throw errors. Can you make it not throw errors when I am not passing the chapter=TITLE,section=TITLE arguments to my class? – user Nov 04 '19 at 01:52
  • I managed to do it and posted it as another answer. – user Nov 04 '19 at 04:33
0

After finding testing for a documentclass option I managed to fix the error throw when the options chapter=TITLE,section=TITLE are not passed to the class:

\documentclass[english,12pt,a4paper,twoside,chapter=TITLE,section=TITLE,]{abntex2}

\makeatletter
  \@ifclasswith{abntex2}{chapter=TITLE}{
    \begingroup
    \def\x#1chapter=TITLE,#2\@nil{%
      \endgroup\def\@classoptionslist{#1#2}%
    }\expandafter\x\@classoptionslist\@nil
  }{}

  \@ifclasswith{abntex2}{section=TITLE}{
    \begingroup
    \def\x#1section=TITLE,#2\@nil{%
      \endgroup\def\@classoptionslist{#1#2}%
    }\expandafter\x\@classoptionslist\@nil
  }
\makeatother

\usepackage[newfloat,chapter,outputdir=setup/cache]{minted}

\begin{document}
Hi.
\end{document}
user
  • 4,745