How to wrap output code when printing an error with a large content in html and LateX? #9517
-
DescriptionI am writing a book and I want to know if it is possible to wrap output when printing an error with a large content in both html and LateX formats. Steps to reproduce---
title: "Untitled"
format:
html:
embed-resources: true
pdf: default
editor: visual
---
# Section 1
```{r}
#| error: true
x <- c("a", "b")
sample(x = x, size = 3)
``` Actual behaviorhtmlDesire behaviorWhat I try but what I want to improveThis can be a solution but what I want is something more automatic, if possible. Any help will be appreciated. ---
title: "Untitled"
format:
html:
embed-resources: true
pdf: default
editor: visual
---
# Section 1
```{r}
#| error: true
x <- c("a", "b")
sample(x = x, size = 3)
```
```{r}
#| eval: false
x <- c("a", "b")
sample(x = x, size = 3)
```
```{r}
#| echo: false
cat("Error in sample.int(length(x), size, replace, prob) : cannot take a sample \nlarger than the population when 'replace = FALSE'")
``` Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
A bit of vocabulary, that's not "responsive" that you are looking for but code output wrapping. Here are some of the previous discussions on this exact topic:
|
Beta Was this translation helpful? Give feedback.
-
Thank you for your help and pointing me out the correct concept in relation to output wrapping. I edit the post taking into account what you mention. However I have some questions. If I try the following solution: ---
title: "Untitled"
format:
html:
embed-resources: true
code-overflow: wrap
pdf:
keep-tex: true
include-in-header:
text: |
\usepackage{fvextra}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}}
include-before-body:
text: |
\RecustomVerbatimEnvironment{verbatim}{Verbatim}{
showspaces = false,
showtabs = false,
breaksymbolleft={},
breaklines
% Note: setting commandchars=\\\{\} here will cause an error
}
editor: visual
---
# Section 1
```{r}
#| echo: false
grid::unit(lattice::trellis.par.get()$axis.components$bottom$tck, lattice::lattice.options()$layout.widths$right.padding$units)
```
```{r}
library(tidyverse)
```
```{r}
#| error: true
x <- c("a", "b")
sample(x = x, size = 3)
```
It is possible to get rid of
As you can check |
Beta Was this translation helpful? Give feedback.
-
Thank you Mickaël Canouil and Christophe Dervieux for your help. As always you really help the Quarto final user. |
Beta Was this translation helpful? Give feedback.
A bit of vocabulary, that's not "responsive" that you are looking for but code output wrapping.
Here are some of the previous discussions on this exact topic: