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

Paragraph after code block renders incorrectly in latex #1789

Open
dellaert opened this issue Jan 19, 2025 · 2 comments
Open

Paragraph after code block renders incorrectly in latex #1789

dellaert opened this issue Jan 19, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@dellaert
Copy link

Description

I encountered another instance where in latex a new paragraph is started (and hence text appears indented) which does not match the output on the web. As with display equations, it would be good if the user could control this, i.e.:

  • if no newline is present after a code block, don't start a new paragraph in latex
  • if there is a newline is present after a code block, DO start a new paragraph

The problem I believe is that a newline is always inserted in latex, which corresponds to case 2 - even if the user does not have a newline.

Test case

Here is a test case that is problematic:

Markdown source: (with two quotes standing in for three)

Above we created an instance of the `gtsam.DiscreteDistribution` class. As with any GTSAM class, you can type
``python
help(gtsam.DiscreteDistribution)
``
to get documentation on its constructors and methods. 

Web rendered:

Image

PDF Rendered:

Image

Latex source(with erroneous extra newline):

Above we created an instance of the \texttt{gtsam.DiscreteDistribution} class. As with any GTSAM class, you can type

\begin{minted}[breaklines]{python}
help(gtsam.DiscreteDistribution)
\end{minted}

to get documentation on its constructors and methods. In particular, we called the constructor

Proposed Fix

I believe the latex should be

Above we created an instance of the \texttt{gtsam.DiscreteDistribution} class. As with any GTSAM class, you can type
\begin{minted}[breaklines]{python}
help(gtsam.DiscreteDistribution)
\end{minted}
to get documentation on its constructors and methods. In particular, we called the constructor

The practice of inserting newlines before and after environments like these creates "new paragraph" issues. Should be fixed for minted, listings, verbatim etc., I think.

@dellaert dellaert added the bug Something isn't working label Jan 19, 2025
@dellaert
Copy link
Author

As an aside, something similar is happening with lists in markdown. This markdown

We assign labels to these actions as follows:

* $a_1$: put in glass bin
* $a_2$: put in metal bin
* $a_3$: put in mixed paper bin
* $a_4$: nop (let the object continue, unsorted)

and each of these actions can be applied at any stage of execution.

yields a new paragraph in latex. Here the newline is needed in the source, because otherwise the list is not terminated - which I guess is standard in markdown. So maybe a newline should only be inserted in latex if two newlines are present in the source.

@rowanc1
Copy link
Member

rowanc1 commented Jan 20, 2025

For styling these now, you can use {raw:tex}`\noindent`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants