Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross refs with memoir and beamerarticle broken #39

Open
dbosk opened this issue Mar 6, 2024 · 6 comments
Open

Cross refs with memoir and beamerarticle broken #39

dbosk opened this issue Mar 6, 2024 · 6 comments
Labels
wrong package As far as I can tell, this issue is caused by a fault in another package, not in noweb

Comments

@dbosk
Copy link
Contributor

dbosk commented Mar 6, 2024

I get the following broken output when using the memoir class with cross-refs enabled:

image

Turning off cross-refs works, of course.

Adding hyperref to the preamble, makes it work as it should:

image

Adding cleveref after that also works.

I have no idea why it breaks with memoir without the hyperref package, further investigation pending. I'll put this here for now, it might help someone in the meantime. (Took me a while to figure this out. I realized it must be related to hyperref after recognizing that noweb. prefix in section 2.11 Support for hypertext of /src/tex/support.nw.)

Final note: The code that is broken with memoir works when article is used instead of memoir, i.e. without the hyperref package and cross-refs enabled.

@nrnrnr
Copy link
Owner

nrnrnr commented Mar 9, 2024

If you get a minimal working example, I'll have a look.

Past experiences with memoir have been gnarly, so no guarantees.

@dbosk
Copy link
Contributor Author

dbosk commented Mar 9, 2024

Trying to make the MWE, I encountered this:

\documentclass[oldfontcommands]{memoir}
\usepackage{noweb}

\begin{document}
@

<<test>>=
print("Hello, world!")
@

\end{document}

Compiling as follows:

noweave -delay -n -x test.nw > test.tex
pdflatex test.tex
pdflatex test.tex

Gives the following error:

! Undefined control sequence.
\nwblindhyperanchor #1->\hypertarget 
                                     {noweb.#1}{\relax }
l.10 ...\nwbegincode{2}\sublabel{NW2dKK4X-Joiug-1}
                                                  \nwmargintag{{\nwtagstyle{...

This seems related. Probably I have another package that originally made it compile without errors, but with the malformed output. To be continued ...

Edit: Checked if hyperref fixes the problem, it does.

\documentclass[oldfontcommands]{memoir}
\usepackage{noweb}
\usepackage{hyperref}

\begin{document}
@

<<test>>=
print("Hello, world!")
@

\end{document}

@dbosk
Copy link
Contributor Author

dbosk commented Mar 9, 2024

%\documentclass[oldfontcommands]{memoir}
\documentclass{article}
\usepackage{beamerarticle}
\usepackage{noweb}

\begin{document}
@

<<test>>=
print("Hello, world!")
@

\end{document}

Seems like the culprit is beamerarticle, not memoir:
image

Still not exactly the same result as above, so probably another package interplaying. (In this one all refs are broken, in the original only the one in the margin is broken.) To be continued ...

Edit: Just wanted to check if hyperref fixes the problem, it does.

%\documentclass[oldfontcommands]{memoir}
\documentclass{article}
\usepackage{noweb}
\usepackage{beamerarticle}
\usepackage{hyperref}

\begin{document}
@

<<test>>=
print("Hello, world!")
@

\end{document}

@dbosk
Copy link
Contributor Author

dbosk commented Mar 9, 2024

Switching from article to memoir in the last example gets me the same broken output as in the original example.

\documentclass[oldfontcommands]{memoir}
%\documentclass{article}
\usepackage{noweb}
\usepackage{beamerarticle}

\begin{document}
@

<<test>>=
print("Hello, world!")
@

\end{document}

This yields
image

@dbosk dbosk changed the title Cross refs with memoir broken Cross refs with memoir and beamerarticle broken Mar 9, 2024
@nrnrnr
Copy link
Owner

nrnrnr commented Mar 12, 2024

I've confirmed that the bug occurs using noweave -delay -x.

Running with tracing on, near as I can tell the Beamer package is taking over \hypertarget:

~...\nwblindhyperanchor #1->\hypertarget {noweb.#1}{\relax }
#1<-NWhiacx-Joiug-1

~...\hypertarget ->\beamer@sort \beamerx@\hypertarget {2}

~....\beamer@sort #1#2->\def \beamer@todo {#1}\def \beamer@ospec {}\beamer@args
count =#2\relax \beamer@parseargs 
#1<-\beamerx@\hypertarget 
#2<-2
{\def}
{changing \beamer@todo=undefined}
{into \beamer@todo=macro:->\beamerx@\hypertarget }
{\def}
{changing \beamer@ospec=undefined}
{into \beamer@ospec=macro:->}
{\count327}
{changing \count327=1}
{into \count327=2}
{\relax}

As far as I can tell, noweb is using \hypertarget in accordance with its API. So it might be time to talk to the Beamer people.

@nrnrnr nrnrnr added the wrong package As far as I can tell, this issue is caused by a fault in another package, not in noweb label Mar 12, 2024
@dbosk
Copy link
Contributor Author

dbosk commented Mar 15, 2024

Great, thanks a lot! I should have a look at Beamer and check in with the Beamer maintainer.

Did you also look at the pure memoir case above? There \hypertarget seemed to be undefined. The memoir manual states that it doesn't do any hyperlinking, that's left for other packages such as hyperref. But noweb checks for that, right? Because we don't get that problem with just article. So there should be something that tricks noweb's checks.

The two cases to compare are

\documentclass{article}
\usepackage{noweb}

\begin{document}
@

<<test>>=
print("Hello, world!")
@

\end{document}

and

\documentclass[oldfontcommands]{memoir}
\usepackage{noweb}

\begin{document}
@

<<test>>=
print("Hello, world!")
@

\end{document}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wrong package As far as I can tell, this issue is caused by a fault in another package, not in noweb
Projects
None yet
Development

No branches or pull requests

2 participants