Skip to content

LaTeX writer: Use a declaration for tight lists #1571

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

Merged
merged 1 commit into from
Apr 18, 2015
Merged

LaTeX writer: Use a declaration for tight lists #1571

merged 1 commit into from
Apr 18, 2015

Conversation

jlduran
Copy link
Contributor

@jlduran jlduran commented Aug 27, 2014

Currently, pandoc has hard-coded the following in order to make tight lists in LaTeX:

text "\\itemsep1pt\\parskip0pt\\parsep0pt"

Which is fine, but does not allow customizations. For example, the memoir class already has a \tightlist declaration for this purpose:

\newcommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

I'm proposing to use a similar solution:

@@ In Writers/LaTeX.hs:
-then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
+then text "\\tightlist"

@@ In templates/default.latex:
+\newcommand{\tightlist}{%
+  \setlength{\itemsep}{1pt}\setlength{\parskip}{0pt}\setlength{\parsep}{0pt}}

This allows us to customize the tightness to our needs.

Backward Compatibility

If a person is using a custom LaTeX template (not based upon the memoir class), the \tightlist declaration must be added.

Currently, pandoc has hard-coded the following in order to make tight lists in
LaTeX:

```hs
text "\\itemsep1pt\\parskip0pt\\parsep0pt"
```

Which is fine, but does not allow customizations.  For example, the `memoir`
class already has a `\tightlist` declaration for this purpose:

```tex
\newcommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
```

I'm proposing to use a similar solution:

```diff
@@ In Writers/LaTeX.hs:
-then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
+then text "\\tightlist"

@@ In templates/default.latex:
+\newcommand{\tightlist}{%
+  \setlength{\itemsep}{1pt}\setlength{\parskip}{0pt}\setlength{\parsep}{0pt}}
```

This allows us to customize the tightness to our needs.

Backward Compatibility

If a person is using a custom LaTeX template (not based upon the `memoir`
class), the `\tightlist` declaration must be added.
@xelatihy
Copy link

xelatihy commented Oct 6, 2014

This would be a great addition! I wonder if the same could be done for the horizontal rule.
I use both in my documents and have to postprocess pandoc output to fix it.

On a side note, it would also be possible to use another environment, such as compactlist/compactenum from package enumitem. But this would only work if all items of the list are compact, which I believe is what pandoc AST does.

@jgm jgm merged commit 9557eb6 into jgm:master Apr 18, 2015
@jlduran jlduran deleted the latex-tightlist branch April 18, 2015 05:24
@jiuks
Copy link

jiuks commented May 28, 2015

I'm getting a tightlist error when I try and convert documents now - is there some extra configuration required.

! Undefined control sequence.
l.80 \tightlist

@nkalvi
Copy link

nkalvi commented May 28, 2015

@jiuks Are you getting this with Pandoc 1.14? It was released a few hours ago.
If the error is with 1.14, could you please provide sample source and the command line so that I can also test?

@jlduran
Copy link
Contributor Author

jlduran commented May 28, 2015

@jiuks You are probably using a custom template. Pandoc now uses a \tightlist declaration that must be defined in your preamble. Try adding:

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

To the preamble of your custom template.

@jiuks
Copy link

jiuks commented May 28, 2015

Thanks - I downloaded the default template and re-configured mine, so all now fixed.

@ghost
Copy link

ghost commented Jul 23, 2015

This change could influence lots of customized templates by resulting in an LaTeX error:

! Undefined control sequence.
l.40 \tightlist

Since Pandoc doesn't show the specific .tex source file to be built, this kind of error comes hard to locate.

In addition, in the world of LaTeX, we don't recommend one to use this kind of tricky to define a tight list. The better way, and also the suggested way of making a tight list is to use the package enumitem as follows:

\usepackage{enumitem}
\setlist{nosep, noitemsep}

@jgm
Copy link
Owner

jgm commented Jul 23, 2015

The advantage of the present method is that it doesn't add a
dependency on an external package, enumitem. It also gives
users the ability to customize the amount of spacing.

If you use the default template, you'll be all right.
If you're using an old, customized template, then with the
change you propose there will still be an error.

I think this issue needs more discussion, but it should be
on pandoc-discuss rather than here (where only a few people will see it).

+++ Liam Huang [Jul 22 15 23:28 ]:

This change could influent lots of customized templates by resulting in
an LaTeX error:
! Undefined control sequence.
l.40 \tightlist

Since Pandoc doesn't show the specific .tex source file to be built,
this kind of error comes hard to locate.

In addition, in the world of LaTeX, we don't recommend one to use this
kind of tricky to define a tight list. The better way, and also the
suggested way of making a tight list is to use the package enumitem as
follows:

\usepackage{enumitem}
\setlist{nosep, noitemsep}


Reply to this email directly or [1]view it on GitHub.

References

  1. LaTeX writer: Use a declaration for tight lists #1571 (comment)

@jlduran
Copy link
Contributor Author

jlduran commented Jul 23, 2015

@LiamHuang0205 looking at the source of enumitem, the current declaration of \tightlist should do exactly the same thing, without the need to include an additional package.

Also remember that pandoc differentiates between loose and compact lists. Wouldn't the use of your suggestion affect both types of lists?

dunn added a commit to dunn/mb-dotfiles that referenced this pull request Aug 8, 2015
lukasmartinelli pushed a commit to manuelroth/osm2vectortiles-thesis that referenced this pull request Sep 15, 2015
jxsw added a commit to jxskiss/pandoc-templates that referenced this pull request Sep 27, 2015
viroulep added a commit to viroulep/worldcubeassociation.org that referenced this pull request Jan 20, 2016
Pandoc >= 1.14 introduced the `\tightlist` command when generating lists.
The declaration must be added when using a custom Latex template : see the "Backward compatibility" section here : jgm/pandoc#1571.

Closes #334 ;)
rm-- added a commit to rm--/MA-FCA that referenced this pull request May 12, 2016
evanpurkhiser added a commit to evanpurkhiser/resume that referenced this pull request Oct 11, 2016
rm-- added a commit to rm--/MA-FCA that referenced this pull request Sep 14, 2017
davejm pushed a commit to davejm/dissertation-report that referenced this pull request Jul 23, 2018
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 this pull request may close these issues.

5 participants