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

PDF metadata with formatted titles #4

Open
devmotion opened this issue Sep 7, 2022 · 8 comments
Open

PDF metadata with formatted titles #4

devmotion opened this issue Sep 7, 2022 · 8 comments

Comments

@devmotion
Copy link
Contributor

I noticed that currently the PDF metadata is incorrect if title: contains formatted parts such as [...]{.pkg} or [...]{.proglang}, even if title-plain is specified. The problem seems to be that the default Pandoc template (re-)sets the metadata and overrides the metadata generated by the JSS class file (which uses the plain title).

I think there are two main options:

  • Use title for the plain title and a new optional title-formatted for the formatted title (similar to the keywords); then the Pandoc template would automatically use the plain title whenever it falls back to the title information and resetting the metadata would not mess up the title metadata
  • Do not use the default Pandoc template (which also e.g. already loads lmodern) but rather use a custom reduced template and include only desired Pandoc partials for e.g. tables but not the hypersetup block

I guess the second alternative would be cleaner since it would not reset and redefine things already handled by the JSS class file.

@dragonstyle
Copy link
Collaborator

Can you point me at the LaTeX that isn't correct in this case? I'm having trouble finding it when title-plain is specified (all looks well to my eyes, but I'm likely just missing where things are not being handled properly).

@devmotion
Copy link
Contributor Author

I'm not completely sure how the incorrect parts looked like exactly, so I tried to reproduce it with b4dd1ab and

---
title: "An [R]{.proglang} Package"
title-plain: "An R Package"
format:
  pdf: default
  jss-pdf:
    keep-tex: true
    pdf-engine: pdflatex
---

(I am sure I used pdflatex since the JSS style guide mentions that the document should be compiled with pdflatex.)

The resulting TeX file then contains

\hypersetup{
  pdftitle={An  Package},
  colorlinks=true,
  linkcolor={blue},
  filecolor={Maroon},
  citecolor={Blue},
  urlcolor={Blue},
  pdfcreator={LaTeX via pandoc}}

which is included by the default Pandoc template that is based only on the title metadata. (As mentioned above, there are other redundant and unnecessary statements included by the Pandoc template as well such as \usepackage{lmodern}.)

However, in contrast to the OP in my experiment actually the incorrect Pandoc metadata was overwritten by the default metadata of the JSS class file, and not the other way around (https://github.com/quarto-journals/jss/blob/main/_extensions/jss/jss.cls#L453 and

pdftitle = {\@Plaintitle},
). I'm not sure why that was not the case when I opened the issue in September.


I also saw your recent commit (a5b928a) that adds a title-plain if only title is specified. I don't think that's necessary or helpful in this case though since the Quarto extension seems to use title-plain only (optionally) in

$if(title-plain)$
\Plaintitle{$title-plain$} %% without formatting
$endif$
and the JSS class file already sets the plain title to the title if it is not specified (
\Plaintitle{\@title}
and
\Plaintitle{\@title}
)

@dragonstyle
Copy link
Collaborator

I don't think that's necessary or helpful in this case though since the Quarto extension seems to use title-plain only (optionally) in

Good call I didn't think to look in the class file itself. I'll revert that change!

@FinYang
Copy link

FinYang commented Jan 24, 2024

I am having this issue with pandoc v3.1.11.1.

@dragonstyle
Copy link
Collaborator

We're happy to help - you'll need to provide some additional information in order for us to do so.

Currently if I:

mkdir test
cd test
quarto use template quarto-journals/jss  --no-prompt
quarto render test.qmd

It successfully renders.

@FinYang
Copy link

FinYang commented Jan 25, 2024

Yes. Sorry, I realised I should provide more information but my issue is exactly as described in the earlier posts so I didn't think of anything to add.

The problem is with markups in the title. If I use

mkdir test
cd test
quarto use template quarto-journals/jss  --no-prompt
sed -i '' '2s/\(.*\)/title: "A Short Demo Article: Regression Models for Count Data in [R]{.proglang}"\ntitle-plain: "A Short Demo Article: Regression Models for Count Data in R"/' test.qmd
quarto render test.qmd

where the extra line is to replace "R" in the title with [R]{.proglang} and add another line of title-plain,
the tex file I get contains

\hypersetup{
  pdftitle={A Short Demo Article: Regression Models for Count Data in },
  pdfauthor={Achim Zeileis; Second Author},
  pdfkeywords={JSS, style guide, comma-separated, not capitalized, R},
  colorlinks=true,
  linkcolor={blue},
  filecolor={Maroon},
  citecolor={Blue},
  urlcolor={Blue},
  pdfcreator={LaTeX via pandoc}}

You can see how "R" with the markup is ignored at the end of pdftitle.

I am using quarto v1.4.549 and pandoc 3.1.11.1. Let me know if you need anything else.

@dragonstyle
Copy link
Collaborator

Ok I can reproduce this using the above - the document titles are correct in this case, but the hypersetup option is incorrect.

Currently, to fix this, the JSS format would need to entirely replace the core pdf template, since that is where the hyper ref options are set. That is a big bite (and will create maintenance headaches going forward), so this is something that I'd like to avoid.

Question - how does the incorrect title manifest itself in the rendered document? Just trying to weight how much to invest in trying to patch / fix this...

@FinYang
Copy link

FinYang commented Jan 26, 2024

It doesn't... as far as I can tell. Even the title in the pdf metadata comes from title-plain and not hypersetup. As long as the journal is ok with it, I guess you don't need to fix it really.

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

No branches or pull requests

3 participants