0

Consider the following MWE:

\documentclass{article}

\usepackage{kpfonts}
\usepackage[utf8]{inputenc}

\begin{document}

This is a formula: $¬¬p \implies p$

\end{document}

The output does not typeset the ¬ unicode symbol (NOT SIGN) and I get this warning:

LaTeX Warning: Command \textlnot invalid in math mode on input line 8

It seems that kpfonts is taking care of handling ¬ but it assigns to it a command that works in text mode (which seems a strange default since this is a mathematical symbol).

How can I redefine the symbol to something usable in math mode (e.g. \lnot) or, better, to make it expand to \textlnot in text mode and \lnot in math mode?

1

The definition of ¬ as \textlnot is done by inputenc with the utf8 option, because kpfonts loads textcomp and ts1enc.dfu has

\DeclareUnicodeCharacter{00AC}{\textlnot}

You can load newunicodechar and fix it.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{kpfonts}
\usepackage{newunicodechar}

\newunicodechar{¬}{\TextOrMath{\textlnot}{\lnot}}

\begin{document}

This is a formula: $¬¬p \implies p$

\end{document}

enter image description here

0

Something like this (making it active)?

\documentclass{article}

\usepackage{kpfonts}
\usepackage[utf8]{inputenc}

\catcode"00AC=\active
\def¬{\ifmmode\lnot\else\textlnot\fi}

\begin{document}

This is a formula: $¬¬p \implies p$

\end{document}
  • That works, but since the kpfonts package already does something similar, I was asking rather how to plug into the same mechanism used by the package. Does the package simply make it active and redefines it as \textlnot? or is it something to do with the inputenc package and the handling of unicode characters? – gigabytes Sep 30 '18 at 15:44
  • @gigabytes I just grep'ed the source code of kpfonts.sty and could not find anything related to lnot. I would guess it is inputenc related, but I don't know. What's the problem with just redefining it? The output looks quite right. – TeXnician Sep 30 '18 at 15:48
  • no problem, I was just trying to understand what was going on under the hood. – gigabytes Sep 30 '18 at 16:00

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.