LaTeX Error: Environment pandoccrossrefsubfigures undefined - latex

I'm trying to render a Markdown document as PDF using pandoc. It includes subfigures and cross-references. When producing the PDF, I get this error message:
! LaTeX Error: Environment pandoccrossrefsubfigures undefined.
I'm using macOS Catalina 10.15.7, pandoc 2.14.1, and pandoc-crossref.
Is there any way to avoid this error?

The problem here is perfectly described in the error message: the environment pandoccrossrefsubfigures doesn't exist, and this prevents the creation of the PDF file.
To solve the problem, just create a new, known environment to replace the missing one:
\newenvironment{pandoccrossrefsubfigures}
{
\begin{figure}
}
{
\end{figure}
}
As a result, the environment named pandoccrossrefsubfigures will be replaced by one named figure that pandoc will recognize.
For more information about this problem, there is an issue on GitHub where pandoc-crossref's author explains the reasons behind this problem, and also provides multiple solutions.

Related

latex todonotes-package throws error in combination with ieeeojies.cls document class

When I am trying to use the todonotes-package within the IEEE OJIES template, by just adding \usepackage{todonotes}, latex throws a “Missing number, treated as zero.” error.
It seems to me that something is in conflict with things in the ieeeojies.cls class-file. If I use the IEEEtran.cls as a document class, no error is thrown.
Here is the link to the template in overleaf:
https://www.overleaf.com/latex/templates/ieee-open-journal-of-the-industrial-electronics-society-template/nhkhktxkdsgf
I am used to work with the todonotes-package, so can please somebody with more latex experience help me out here?
The problem is the naughty redefinition of \year in the class.
You can avoid the error by loading pgf before the class so it still gets to see the correct definition of year instead of the strange things the class does to it
\RequirePackage{pgf}
\documentclass{ieeeojies}
\usepackage{todonotes}
\begin{document}
\EOD
\end{document}

Sphinx cross-reference in LaTeX

I have the following reference identified in file A:
.. _my-label:
and I reference it in file B :
this is a reference to file A :ref:`my-label`
This generates a cross-reference as expected when outputting HTML. However, when outputting LaTeX, it does not and I have the classical warning:
LaTeX Warning: Hyper reference `my-label:my-label' on page XX undefined on input line YY.
Is there a LaTeX trick like double compilation or something similar that I am not doing correctly?
I encountered the same issue. HTML compiled without errors for me, but LaTeX compilation did throw the hyperref errors you described. It seems to me that, for some obscure reason, Sphinx does not create the labels that hyperref tries to reference.
I came up with the following solution: since I do not know how to include the missing labels, I will just make it so that LaTeX does not look for them anymore. In detail, I am doing this by overwriting the \hyperref command.
I included the following code in my conf.py file:
latex_elements = {
'preamble': r'''
\renewcommand{\hyperref}[2][]{#2}
'''
}
This includes the \renewcommand{... in the preamble of the LaTeX document created by Sphinx. It will overwrite the \hyperref command so that it won't try to insert a link, but just print the link text.
Obviously, with this solution, the reference that caused the errors will not appear as hyperlinks in your PDF document, but at least it is compiling without errors.
Note
What I described worked perfectly fine for my use case, however, it is described in the Hyperref manual that the \hyperref command can be invoked in two different ways (\hyperref{URL}{category}{name}{text} and \hyperref[label]{text}). I am only overwriting the second one, as that seems to be the one that Sphinx is using for cross references. However, not accounting for the first one when overwriting the command might lead to issues in some cases.

Why jupyter is not able to download as pdf a markdown cell using LaTex \mathscr?

Just created a markdown cell in Jupyter using some equations, and some of them using \mathscr to have like "math" fonts. When I run the kernel containing the equations everything is ok, however when I click the option to Download as PDF via LaTex, I'm getting the error below:
! Undefined control sequence.
l.300 [\mathscr
{L}({\bf{y}}|\beta, \sigma^2, {\bf{X}}) = (2\pi\sigma^2)^{-...
?
! Emergency stop.
l.300 [\mathscr
{L}({\bf{y}}|\beta, \sigma^2, {\bf{X}}) = (2\pi\sigma^2)^{-...
If I remove the \mathscr part everything can be exported with no issues (excepting some convertion problems for special characters), however, I wanted to know ho to solve it. I've been reading and it looks like the nbconvert configuration file can be modified to solve this, but I couldn't find the mentioned file and the exact way to modify it
Thanks for your help
I think the problem is with absent \usepackage{mathrsfs} directive in an intermediate .tex-file.
So you have a several ways to overcome it.
If you face with this problem occasianaly you could the following:
download the .tex-file instead pdf;
manually insert to \usepackage{mathrsfs} to it.
before the first \usepackage for example;
run something like
xelatex file.tex to finally convert to pdf.
If you will do it often, you could try to edit appropriate jinja-template.
At first, find the place where nbconvert was installed. For example with pip: pip show nbconvert. Imagine the path is /home/i/.local/lib/python3.5/site-packages
Then the template would be at /home/i/.local/lib/python3.5/site-packages/nbconvert/templates/latex/base.tplx.
And again: just add \usepackage{mathrsfs} right after ((* block packages *)).
Voila -- the problem should gone.
At the end you have the third option -- you can create your own template from scratch and use it with nbconvert. I don't think it's very convenient way to solve your problem. You could read more in the documentation: http://nbconvert.readthedocs.io/en/latest/customizing.html

Atom keybindings and the LaTeX package

I want to change the keybinding for building in LaTeX from the default ctrl-alt-b to cmd-b. Settings suggests I copy paste
'atom-text-editor[data-grammar~='latex']':
'cmd-b': 'latex:build'
into the keymap.cson file but upon saving it I get the error message
[stdin]:20:34: error: unexpected latex
'atom-text-editor[data-grammar~='latex']':
^^^^^
Since the whole expression is inside a pair of single quotes, you need to use different quotes around latex:
"atom-text-editor[data-grammar~='latex']":
or
'atom-text-editor[data-grammar~="latex"]':
Also note, that you will likely run into a conflict with existing keybindings. The keybinding-resolver package is a great helper to find conflicting keybindings.

How do I find the location of a Doxygen latex error?

My question is similar to this one.
Doxygen is outputing a warning while trying to generate docs for HTML:
warning: reached end of file while inside a f$ block!
The command that should end the block seems to be missing!
I understand what this means, but I have lots of LaTeX in this particular document. Unfortunately, the line number of the error is just the last line in the file, and Doxygen doesn't output the the \f$ that opened the math mode.
Is there a way to get Doxygen to output this, rather than me having to scour the file for a missing or malformed \f$? Something that might produce more verbose errors?
Before I finished typing this question, I found the offending line by browsing the generated HTML and looking for a function in that file that didn't get documented. That at least gave me enough of a hint for where to start looking. Still it would be great if there was a more concrete answer to this.
When generating for Latex with Doxygen, it is indeed not obvious to spot errors. One solution is to get down into the latex generated folder, and try these steps:
Run generated makefile ($ make), and look for pdflatex compiler output,
If it fails, load the file refman.tex into some Latex IDE (say, Texstudio or equivalent) and try to compile from there.
If still unable to locate error, you can run manually pdflatex with option halt-on-error:
($ pdflatex -halt-on-error refman.tex). This way, it will stop immediately at the error location.

Resources