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

Newline (\\) suddenly doesn't work #1601

Closed
3 tasks done
yarnabrina opened this issue Jul 12, 2019 · 4 comments
Closed
3 tasks done

Newline (\\) suddenly doesn't work #1601

yarnabrina opened this issue Jul 12, 2019 · 4 comments

Comments

@yarnabrina
Copy link

yarnabrina commented Jul 12, 2019

If I use \\ inside $$, a new line is not created anymore. Consider the following example:

---
title: "Example"
output: pdf_document
---

some text

$$
just \ some \ more \ text \\
again \ some \ more \ text \\
once \ again \ more \ text
$$

some text

This generates the following file: try.pdf

Screenshot:

image

As you can find there, the three sentences in the .Rmd file separated by \\ are in same line in the rendered document. However, the preview displays correctly, and if I render as HTML, it works there too.

Here's my sessioninfo:

xfun::session_info('rmarkdown')
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18362)
#> 
#> Locale:
#>   LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252   
#>   LC_MONETARY=English_India.1252 LC_NUMERIC=C                  
#>   LC_TIME=English_India.1252    
#> 
#> Package version:
#>   base64enc_0.1.3  digest_0.6.20    evaluate_0.14    glue_1.3.1      
#>   graphics_3.6.1   grDevices_3.6.1  highr_0.8        htmltools_0.3.6 
#>   jsonlite_1.6     knitr_1.23.3     magrittr_1.5     markdown_1.0    
#>   methods_3.6.1    mime_0.7         Rcpp_1.0.1       rmarkdown_1.14.1
#>   stats_3.6.1      stringi_1.4.3    stringr_1.4.0    tinytex_0.14    
#>   tools_3.6.1      utils_3.6.1      xfun_0.8         yaml_2.2.0      
#> 
#> Pandoc version: 2.6

By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.name/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('rmarkdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/rmarkdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui
Copy link
Member

yihui commented Jul 12, 2019

By "suddenly", how sudden was it? When did it work before?

I doubt if it ever worked at all. I'm not a LaTeX expert, but a quick Google search of "latex linebreak in math mode" led to several StackExchange posts, and all of them said \\ wouldn't work in the display math mode, e.g.

@yarnabrina
Copy link
Author

By "suddenly", how sudden was it? When did it work before?

I was seriously taken aback while I couldn't find any .Rmd file rendered to PDF where I used only \\ inside $$. Now, this issue seems stupid.

However, \\ does work if I use it within split inside $$. If you substitute the math mode part in my question with the following, it'll be rendered with line breaks.

$$
\begin{split}
just \ some \ & more \ text \\
again \ some \ & more \ text \\
once \ again \ & more \ text
\end{split}
$$

Here's the screnshot:
image

\\ wouldn't work in the display math mode

Also, \\ do work when I render as HTML. Why does it work there? Why should same LaTeX expression have different behaviour while rendered to HTML and PDF?

@yihui
Copy link
Member

yihui commented Jul 13, 2019

Why should same LaTeX expression have different behaviour while rendered to HTML and PDF?

Because LaTeX math is rendered by MathJax (a JS library) in HTML.

@yihui yihui closed this as completed Dec 12, 2019
@github-actions
Copy link

github-actions bot commented Nov 3, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants