paolobrasolin / commutative-diagrams

CoDi: Commutative Diagrams for TeX
https://paolobrasolin.github.io/commutative-diagrams/
MIT License
30 stars 3 forks source link

Flood of warnings concerning "Missing character: There is no * in font nullfont!" #42

Closed Holiverse closed 4 months ago

Holiverse commented 5 months ago

Is there an existing issue for this?

Current behaviour

Recentely, when I use CoDi package in vscode as before, I found there are a lot of warning report that does not happen in the early version.

Expected behaviour

I hope we can find a reason for these numerous inexplicable warnings, and can find a way to fix it.

Steps to reproduce

When using latexmk in vscode to compile the following code

\documentclass[10pt]{article}

\usepackage{commutative-diagrams} 

\begin{document}

\title{Test}
\maketitle

\begin{codi}[prompter]
    \obj {A & B \\};
\end{codi}

\end{document}

There are 16 warnings such as copies of the follow eight

Missing character: There is no p in font nullfont! Missing character: There is no g in font nullfont! Missing character: There is no f in font nullfont! Missing character: There is no e in font nullfont! Missing character: There is no x in font nullfont! Missing character: There is no t in font nullfont! Missing character: There is no r in font nullfont! Missing character: There is no a in font nullfont!

It seems like that these characters are "pgfextra" which I do not understand what does this means. And the number of these warnings might be n*8 where n is the number of the object.

But if we input only one object, there is no warning.

Additional context

No response

paolobrasolin commented 4 months ago

Hi @Holiverse, thanks for the report and for using commutative-diagrams!

The bug you found is annoying, but fortunately it's also completely harmless.

TL;DR: until the next release, you can avoid the warnings by including the package as follows:

\usepackage{commutative-diagrams} 
\let\kDMitraMaybeDumpCell\relax

Explanation

\pgfextra is a TikZ directive to insert extra commands in the middle of a path. I used it to produce debug logs during development.

\kDMitraMaybeDumpCell is the problematic macro https://github.com/paolobrasolin/commutative-diagrams/blob/e68570b97d59446ef78e943b29d47c79fddb9ba4/src/tikzlibrarycommutative-diagrams.mitra.code.tex#L184-L187 and it's used in the routine handling the matrix sintax for objects https://github.com/paolobrasolin/commutative-diagrams/blob/e68570b97d59446ef78e943b29d47c79fddb9ba4/src/tikzlibrarycommutative-diagrams.mitra.code.tex#L177 so it gets called once for every cell.

Unfortunately, \kDMitraMaybeDumpCell is broken because it's calling \pgfextra outside of a path. There is no visible output in the document (nullfont is used in that context and it's not visible) but LaTeX still warns about the missing characters.

Solution 1: fix the issue

The problematic macro can be fixed with a simple override after the package is included (note the added \path ... ;):

\documentclass{article}
\usepackage{commutative-diagrams} 

\def\kDMitraMaybeDumpCell{\noexpand\path\noexpand\pgfextra{%
  \noexpand\kDDump{'\noexpand\the\noexpand\pgfmatrixcurrentrow-\noexpand\the\noexpand\pgfmatrixcurrentcolumn':}%
  \noexpand\kDDump{\space\space options: '\the\kDMitraCelOptTok'}%
  \noexpand\kDDump{\space\space content: '\the\kDMitraCelCntTok'}};}

\kDDumpingtrue

\begin{document}
\begin{codi}[prompter]
    \obj {A & B \\};
\end{codi}

\end{document}

Then, if the development debugging feature is activated with \kDDumpingtrue as in the code above, the following output is produced in the log:

'1-1':
  options: ''
  content: 'A'
'1-2':
  options: ''
  content: 'B'

Arguably, that's useless for the end user.

Solution 2: eliminate the issue (recommended)

Since the broken development debug feature is useless for the end user we can simply excise it:

\documentclass{article}
\usepackage{commutative-diagrams} 
\let\kDMitraMaybeDumpCell\relax

\begin{document}
\begin{codi}[prompter]
    \obj {A & B \\};
\end{codi}

\end{document}
paolobrasolin commented 4 months ago

Just released version 1.1.1 to fix this. :rocket: Thanks @Holiverse!