1

My problem was already covered by this posting: Undefined control sequence with chordbox

I am trying to compile the following document.

\documentclass[11pt,a4paper]{article}
\usepackage{chordbox_bugfix}
\pgfkeys{/chordbox/text on node=pitch}
\tikzset{chordbox/.append style={scale=2.5}}

\begin{document}

\chordbox{Am}{x,0,2,2,1,0}
\chordbox{F}{1:T,3:3,3:4,2:2,1:1,x}
\chordbox{D}{x,x,0,2:1,3:3,2:2}
\chordbox{D}{x,x,0,2,3,2}

\end{document}

The chordbox bugfix works perfectly with the pdflatex and latex compilers. However, using the xelatex compiler raises the following error:

! Undefined control sequence.
\pgffor@body -> \ifnum \pdfmatch 
                                 {^[0-9]+}{\fret }=1 \StrBehind {\pdflastmat...
1.10 \chordbox{Am}{x,0,2,2,1,0}

Could it be that this package does not work with xelatex?

1
  • \pdfmatch is a pdftex primitive not available in other engines Commented Sep 22, 2022 at 16:41

1 Answer 1

1

\pdfmatch seems to be a pdfTeX primitive and hasn't been implemented in Xe(La)TeX for the last 13 years, it seems.

Here's an etoolbox powered fix.

The \pdfmatch simply tests whether the values x, 1:T, 3:3, … start with a digit.

The \pdflastmatch has to be replaced too, originally it expands to the digit(s) before a possible :. I've replaced that with a \StrBefore before the \ifnum test so it isn't necessary here anymore.

In short:

  • Remove line 138.

  • Replace line 137 with

    \StrBefore{\fret:}{:}[\num]
    \IfDecimal{\num}{\def\chordboxresult{1}}{\defchordboxresult{0}}
    \ifnum\chordboxresult=1
    

Code

\documentclass[11pt,a4paper]{article}
\usepackage{chordbox_bugfix}
\pgfkeys{/chordbox/text on node=pitch}
\tikzset{chordbox/.append style={scale=2.5}}
\usepackage{etoolbox}
\patchcmd{\chordboxenv}
  {\StrBehind{\pdflastmatch 0}{>}[\num]}% don't need that anymore
  {}{}{\errmessage{Oh no.}}
\patchcmd{\chordboxenv}
  {\ifnum\pdfmatch{^[0-9]+}{\fret}=1}
  {%
    \StrBefore{\fret:}{:}[\num]% we've got it here now anyway
    % could be x, could be a number, let's test it:
    \IfDecimal{\num}{\def\chordboxresult{1}}{\def\chordboxresult{0}}%
    \ifnum\chordboxresult=1
  }
  {}{\errmessage{Oh no.}}
\begin{document}
\chordbox{Am}{x,0,2,2,1,0}
\chordbox{F}{1:T,3:3,3:4,2:2,1:1,x}
\chordbox{D}{x,x,0,2:1,3:3,2:2}
\chordbox{D}{x,x,0,2,3,2}
\end{document}
1
  • 1
    Thank you very much for this fix! Everything works perfectly now.
    – user281555
    Commented Sep 22, 2022 at 17:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .