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

LaTeX template: fix \CSLRightInline vertical space #9058

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/templates/default.latex
Expand Up @@ -362,7 +362,7 @@ $if(csl-refs)$
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1\\[-1.7ex]}}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this change fixes the problem?

Copy link
Contributor Author

@jpcirrus jpcirrus Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To determine where the additional vertical space was coming from I wrapped the \parbox{} in an \fbox{}. This indicated that it was from the \break outside the \parbox. By moving that inside the \parbox results were consistent regardless of bibitem length, but without negative adjustment were too large. By iteration arrived at the value of -1.7ex. I had previously been using a custom template with \break replaced by \\[-0.7ex] to get spacing that matched the document. Technically why, I don't know.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just seems a bit "magic" and unprincipled...I wonder if there's a better way?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about just removing the \break? Is it needed?
It seems to work fine without it and I don't get the extra space.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During my testing I had initially tried that, but when using a more complex document using article and scrartcl the linespacing was removed between bibitems:


20230905T141943-PDF Expert@2x
20230905T141542-PDF Expert@2x

but having used the above input file with article, scrartcl, apa6 (with the man class option) and beamer it works correctly, so there must be something (not obvious) in that document which is causing the issue which I will sort out.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether, when entry spacing is set to 0, we should just use \parskip instead of actually using 0? In a document that has a \parskip of 6pt (default for pandoc), the bibliography may look odd with 0 space between entries. But maybe that's too opinionated a divergence.

No. I think it would be incorrect in terms of the CSL spec. I believe the current implementation is accurate.

With entry-spacing="0" and \setlength{\itemsep}{#2\baselineskip}}}:

20230908T103846-PDF Expert@2x

and entry-spacing="0" and \setlength{\itemsep}{\parskip}}}:

20230908T103936-PDF Expert@2x

The spacing is approaching what it is when entry-spacing="1". The paragraph spacing has nothing to do with the entry spacing, which had me confused until I read the spec more carefully

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree it's more accurate this way. I just think it's a bit awkward that, with the default 6pt parskip that pandoc gives you without indent, you have a choice between a bigger or a smaller space between bib entries, but no way to get the same...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually prefer the way it is 😃.

20230908T160345-PDF Expert@2x

This is going to be the case with all documents where entry-spacing="0" and indent: false, regardless if using a KOMA class, the parskip package, or the pandoc default of 6pt plus 2pt minus 1pt. In my custom template I used to have the entry-spacing depend on indent. But, I was wrong, due to my ignorance from not having read the spec, assuming 0 meant zero spacing (not zero additional spacing), 1 was line spacing (actually 0)... and which clearly others do too e.g. #7296. But, I can appreciate the visual appeal:

20230908T160629-PDF Expert@2x

rather than moving up to entry-spacing="1":

20230908T160659-PDF Expert@2x

However, if you decide to implement this please don't make it the default, but rather an option, or better yet as a filter, so that at least the default is compliant with the spec. Of course, for those wanting something special, it is always possible to use header-includes:

\usepackage{etoolbox}
\AtBeginEnvironment{CSLReferences}[\setlength{\itemsep}{ANYTHING YOU WISH}

I have completed testing the latex CSL functionality. I have tested with the KOMA, APA, and standard classes, together with beamer. All combinations of linespacing (single, onehalf and double) work correctly with entry-spacing values of 0, 1 and 2, using bibliographies of approx 50–200 items. Thanks very much for your efforts with this, I am really happy with the results.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for the extensive testing! I'll close this.

\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
$endif$
$if(lang)$
Expand Down