Skip to content

Nested code chunks in list #476

@nbenn

Description

@nbenn

Using the current MyJSSArticle.Rmd template, I run into an issue when nesting a code chunk with a list. The following markdown renders to tex as I'd expect:

1. My first entry.

1. My second entry.

gives

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  My first entry.
\item
  My second entry.
\end{enumerate}

However, when I try adding a code chunk (with 4 space indentation), the list is split:

1. My first entry.

    ```{r}
    x <- 1:10
    x
    ```

1. My second entry.

now gives

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
  My first entry.
\end{enumerate}

\begin{CodeChunk}
\begin{CodeInput}
R> x <- 1:10
R> x
\end{CodeInput}
\begin{CodeOutput}
 [1]  1  2  3  4  5  6  7  8  9 10
\end{CodeOutput}
\end{CodeChunk}

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
  My second entry.
\end{enumerate}

This is not specific to JSS, but when trying out the rjournal template, the same behavior can be observed. Is this intentional or a bug?

When using vanilla pdf_document, this of course behaves differently, the tex that is produced is

\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
  My first entry.

\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{x }\OtherTok{\textless{}{-}} \DecValTok{1}\SpecialCharTok{:}\DecValTok{10}
\NormalTok{x}
\end{Highlighting}
\end{Shaded}

\begin{verbatim}
##  [1]  1  2  3  4  5  6  7  8  9 10
\end{verbatim}
\item
  My second entry.
\end{enumerate}

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('rticles'). 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/rticles').
    • 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.

> xfun::session_info('rticles')
# R version 4.1.3 (2022-03-10)
# Platform: aarch64-apple-darwin20 (64-bit)
# Running under: macOS Monterey 12.3
#
# Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8
#
# Package version:
#   base64enc_0.1.3 bslib_0.3.1     digest_0.6.29   evaluate_0.15
#   fastmap_1.1.0   fs_1.5.2        glue_1.6.2      graphics_4.1.3
#   grDevices_4.1.3 highr_0.9       htmltools_0.5.2 jquerylib_0.1.4
#   jsonlite_1.8.0  knitr_1.37      magrittr_2.0.2  methods_4.1.3
#   R6_2.5.1        rappdirs_0.3.3  rlang_1.0.2     rmarkdown_2.13
#   rticles_0.23    sass_0.4.0      stats_4.1.3     stringi_1.7.6
#   stringr_1.4.0   tinytex_0.37    tools_4.1.3     utils_4.1.3
#   xfun_0.30       yaml_2.3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviornextto consider for next release

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions