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

NeurIPS Template Obsolete #250

Closed
andreapisa9 opened this issue Sep 19, 2024 · 11 comments · Fixed by #252
Closed

NeurIPS Template Obsolete #250

andreapisa9 opened this issue Sep 19, 2024 · 11 comments · Fixed by #252

Comments

@andreapisa9
Copy link

andreapisa9 commented Sep 19, 2024

pandoc_version: 3.3
pdftex_version: 3.141592653-2.6-1.40.26 (TeXLive 2024)
obsidian_version: 1.6.7
os: MacOS Sonoma 14.6.1

Hi,

I encounter issues when exporting Obsidian notes into PDF with the NeurIPS TeX template. The following error related to my Pandoc Reference List references appears:

Command: pandoc "/path/to/Obsidian/vault/note.md" -f markdown+wikilinks_title_after_pipe --resource-path="/path/to/Obsidian/vault" --resource-path="/path/to/Obsidian/vault/.obsidian/plugins/obsidian-enhancing-export/textemplate" --lua-filter="/path/to/Obsidian/vault/.obsidian/plugins/obsidian-enhancing-export/lua/pdf.lua" --template="neurips.tex" -o "/path/to/output_folder/note.pdf" -t pdf -pdf-engine=pdflatex --citeproc --bibliography="/path/to/bibliography.bib" --csl="/path/to/cslstyle.csl", Error:Error: Command failed: pandoc "/path/to/Obsidian/vault/note.md" -f markdown+wikilinks_title_after_pipe --resource-path="/path/to/Obsidian/vault" --resource-path="/path/to/Obsidian/vault/.obsidian/plugins/obsidian-enhancing-export/textemplate" --lua-filter="/path/to/Obsidian/vault/.obsidian/plugins/obsidian-enhancing-export/lua/pdf.lua" --template="neurips.tex" -o "/path/to/output_folder/note.pdf" -t pdf -pdf-engine=pdflatex --citeproc --bibliography="/path/to/bibliography.bib" --csl="/path/to/cslstyle.csl" Error producing PDF. ! LaTeX error: Lonely \item--perhaps a missing list environment. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.406 ...iteproctext]{ref-referenceCiteKey}

Using lualatex as pdf-engine gives the same result. I found this issue similar to Zettlr #4879 so I implemented the same workaround and it works perfectly. I report the workaround here for whoever needs it. In /path/to/Obsidian/vault/.obsidian/plugins/obsidian-enhancing-export/textemplate/neurips.tex, change the text from line 50 to line 74 with this:

$if(csl-refs)$
% definitions for citeproc citations
\NewDocumentCommand\citeproctext{}{}
\NewDocumentCommand\citeproc{mm}{%
\begingroup\def\citeproctext{#2}\cite{#1}\endgroup}
\makeatletter
% allow citations to break across lines
\let\@cite@ofmt\@firstofone
% avoid brackets around text for \cite:
\def\@biblabel#1{}
\def\@cite#1#2{{#1\if@tempswa , #2\fi}}
\makeatother
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newenvironment{CSLReferences}[2] % #1 hanging-indent, #2 entry-spacing
{\begin{list}{}{%
	\setlength{\itemindent}{0pt}
	\setlength{\leftmargin}{0pt}
	\setlength{\parsep}{0pt}
	% turn on hanging indent if param 1 is 1
	\ifodd #1
	\setlength{\leftmargin}{\cslhangindent}
	\setlength{\itemindent}{-1\cslhangindent}
	\fi
	% set entry spacing
	\setlength{\itemsep}{#2\baselineskip}}}
{\end{list}}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{\hfill\break\parbox[t]{\linewidth}{\strut\ignorespaces#1\strut}}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{\strut#1\strut}}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
$endif$

Also, on line 10 add nonatbib to the options of package neurips. The export works fine.

YET UNSOLVED PROBLEM: the neurips.tex template file refreshes whenever I restart Obsidian, so I need to re-operate the workaround roughly everyday, which is a nuisance.

Thanks for your support!

@universvm
Copy link
Contributor

universvm commented Sep 24, 2024

Hi @andreapisa9 ,

Apologies, I don't follow the issues on this plugin so in the future please just post on the https://github.com/universvm/obsidian-pandoc-templates/ repo.

My error seems to be related to pandocbounded and simply adding the following fixed the issue:

add at line 36 after \usepackage{graphicx}

\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
  \sbox\pandoc@box{#1}%
  \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
  \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
  \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
  \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
  \else\usebox{\pandoc@box}%
  \fi%
}

I'm using:

❯ pandoc --version
pandoc 3.4
Features: +server +lua
Scripting engine: Lua 5.4

❯ pandoc-crossref --version
pandoc-crossref v0.3.18.0 git commit UNKNOWN (UNKNOWN) built with Pandoc v3.4, pandoc-types v1.23.1 and GHC 9.10.1

I am attaching the tex file for the template.
neurips.tex.zip

Could you let me know if this fixes your problem? If not could you update the version of pandoc and if that doesn't work please send me an example file so I can check on my end

universvm added a commit to universvm/obsidian-enhancing-export that referenced this issue Sep 25, 2024
@andreapisa9
Copy link
Author

The problem is still there using the new file. I'll try to update pandoc to have the same version as yours and report what happens.

@universvm
Copy link
Contributor

@andreapisa9 could you send me your .md file so I can test it on my end as well?

@andreapisa9
Copy link
Author

Nope, updating pandoc and pandoc-crossref did not solve the issue. Would you prefer to continue this in the other repo?

Here is my .md file

Technology and Society Essay.md

@andreapisa9
Copy link
Author

You'll probably need the .bib file as well

PhD.bib.zip

@universvm
Copy link
Contributor

@andreapisa9 it's okay, let's discuss here.

I am able to generate the PDF without bib. Let me try with your bib.
Technology.and.Society.Essay.pdf

@universvm
Copy link
Contributor

Ok I was able to replicate. Indeed your fix works, I'll update the template soon

@andreapisa9
Copy link
Author

Grazie mille!

universvm added a commit to universvm/obsidian-enhancing-export that referenced this issue Sep 25, 2024
@universvm
Copy link
Contributor

@andreapisa9 I submitted a PR, thanks for your help again!

@mokeyish Merging #252 should fix the issue :)

@mokeyish
Copy link
Owner

This problem seems to be easy to encounter.It would be better to add compaitable pandoc version comments in that file. @universvm What do you think?

@universvm
Copy link
Contributor

@mokeyish sounds good. It should be backwards compatible. I've added the version at which I tested it with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants