2

I am trying to create a Tufte-styled document in LyX that incorporates R code output using the knitr library and the Tufte-LaTeX book package. I would like one of my figures generated by R code within the document to be full width (fig.fullwidth = TRUE), spanning both the normal text column and the margin. However, LyX will not produce a PDF with the full width figure; no matter what I do, the figure is always the normal text column width.

I'm at a loss as to why this isn't working. I hoping someone can point me toward a solution.

Below is a minimal reproducible example of a LyX document that shows the problem.

FWIW, if I create the same test document in RMarkdown, the fig.fullwidth flag works as expected. Unfortunately, switching to RMarkdown is not practical for the full document that I'm working on.

Versions:

TeX Live 2017.

R sessionInfo() output:

R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] graphics  grDevices utils     datasets  splines   stats4    stats     methods   base     

other attached packages:
[1] knitr_1.17    randr_0.2.0   randtests_1.0 random_0.2.6  VGAM_1.0-4    numbr_0.1     rmaxmin_0.2.1

loaded via a namespace (and not attached):
[1] compiler_3.4.2 tools_3.4.2    yaml_2.1.14    curl_3.0   

The minimal reproducible example LyX document:

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass tufte-book
\use_default_options true
\begin_modules
knitr
\end_modules
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 2
\tocdepth 2
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
Normal figure output within the Tufte-LaTeX text column:
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout

<<example2>>=
\end_layout

\begin_layout Plain Layout

suppressMessages({
\end_layout

\begin_layout Plain Layout

library(dplyr)
\end_layout

\begin_layout Plain Layout

library(ggplot2)
\end_layout

\begin_layout Plain Layout

})
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

iris %>%
\end_layout

\begin_layout Plain Layout

ggplot(aes(Sepal.Length, Sepal.Width)) +
\end_layout

\begin_layout Plain Layout

geom_point()
\end_layout

\begin_layout Plain Layout

@
\end_layout

\end_inset


\end_layout

\begin_layout Standard
Expect this to be full-width figure output, spanning the text column and
 the margin:
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout

<<example3, fig.fullwidth=TRUE, fig.width = 10>>=
\end_layout

\begin_layout Plain Layout

suppressMessages({
\end_layout

\begin_layout Plain Layout

library(dplyr)
\end_layout

\begin_layout Plain Layout

library(ggplot2)
\end_layout

\begin_layout Plain Layout

})
\end_layout

\begin_layout Plain Layout

\end_layout

\begin_layout Plain Layout

iris %>%
\end_layout

\begin_layout Plain Layout

ggplot(aes(Sepal.Length, Sepal.Width)) +
\end_layout

\begin_layout Plain Layout

geom_point()
\end_layout

\begin_layout Plain Layout

@
\end_layout

\end_inset


\end_layout

\end_body
\end_document
Tom
  • 694
  • 8
  • 20
  • 1
    +1 nice MWE. Perhaps this issue is related in some way to the open bug https://github.com/rstudio/bookdown/issues/312 ? – scottkosty Nov 26 '17 at 22:56
  • @scottkosty yes, that looks like it might be the same issue. Thanks! – Tom Nov 26 '17 at 22:57

0 Answers0