tests/010/notes/Notes.md

title: "Test 010: Diagrams generated by R the right size" author: 'Emma Cliffe, Skills Centre: MASH, University of Bath' date: 'August 2021' site: bookdown::bookdown_site language: en documentclass: article classoption: a4paper fontsize: 10pt geometry: margin=2.5cm output: clavertondown::word_clav: toc: false number_sections: true keep_md: true pandoc_args: --default-image-extension=svg clavertondown::gitbook_clav: split_by: section config: download: [["Notes.html", "HTML page"], ["Notes.pdf","Standard print PDF"], ["NotesClear.pdf","Clear print PDF"], ["NotesLarge.pdf","Large print PDF"], ["Notes.docx","Accessible Word document"], ["Notes.epub","Accessible EPub book" ]] sharing: no pandoc_args: --default-image-extension=svg clavertondown::epub_clav: toc: false pandoc_args: --default-image-extension=svg clavertondown::pdf_clav: latex_engine: pdflatex dev: pdf keep_tex: true fig_caption: true toc: false extra_dependencies: ["float"] pandoc_args: --default-image-extension=pdf clavertondown::html_clav: toc: false pandoc_args: --default-image-extension=svg

Introduction {-}

Problem: In clear and large print we are trying to control the size of the diagrams. This was tested with some cases but a problem was reported with images generated by R.

Attempt: To understand how diagrams generated by R present in the LaTeX, replicate the problem and solve it.

Figures generated by R

Saved and then included

This is as per the example and is working as expected.

Here is a figure

Figure 1.1: This is title and a caption{width="60%"}

Figure inside another built in environment

\BeginKnitrBlock{example}

Example 1.1
Here is an example.

Figure 1.2: Something to do with cars{width="60%"}

This is a test. So, you need an empty line before and after the above for it to be a float. At the end of an environment this means that you need TWO empty lines. This is Pandoc.

\EndKnitrBlock{example}

Generated and included

This is the untested use case as it was not what clavertondown was originally designed to 'fix'. By trying to intercede with all figures, including non-floats, I seem to have broken the world. Which is now fixed.

What happened? If you use R to generate an image without saving and then floating it then no native width and height are set in the includegraphics. If you change the width and height in the R snippet then this is used to generate a different size pdf image NOT to adapt the width and height in includegraphics. This means that when we try to use scaling and adjusting there is no width and height set so Bad Things happen in clear and large print. ALL includegraphics in clear and large print MUST have a width AND height set. Luckily we know that adjustbox is present so when we find such things in the below we can set width=\Width and height=\Height. Note the capitalisation and reread the adjustbox manual if you aren't sure.

plot(cars)



BathMASH/clavertondown documentation built on Oct. 13, 2023, 6:25 p.m.