I am writing a book in Rmarkdown using the tufte
package; which uses tufte-latex
for pdf output. My current issue is that I have not found a way to have a table extend wider than the normal margin of the tufte-latex
output.
Things I have tried:
- Wrapping in the
table*
environment (suggested here); but works only for tables that are less than 1 page long - Wrapping in the
fullwidth
environment; but this has no effect onlongtable
(see here) - Using my
newgeometry
approach, which pushes the table onto a new page, which is not desirable \setlength\LTleft
and\setlength\LTright
(here); I can set one or the other (e.g. move the table to the right margin), but setting both doesn't alter the width. I think this is because the column sizes are fixed by Pandoc?
Things I have read but don't understand:
- Redefining the longtable environment here looks promising, but I don't entirely understand the answer
Things I can do:
- I can use Pandoc filters to wrap latex output in additional commands or environment wrappers. e.g. I have a filter that identifies a wide table and places it in a
\landscape
layout (although this it does not solve the column-overlap issue). - I can change the latex template the Pandoc uses, so I can call additional options/use packages
Key restrictions are that:
- Tables compile cleanly to both html and latex; i.e. it can take a markdown table as an input, and does not require explicit specification of column width
- It can handle tables longer than one page
Here is an example table/document, generated by pandoc.
\documentclass[a4paper]{tufte-book}
% ams
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\makeatletter
\@ifpackageloaded{fontspec}{}{\usepackage{fontspec}}
\makeatother
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\makeatletter
\@ifpackageloaded{soul}{
\renewcommand\allcapsspacing[1]{{\addfontfeature{LetterSpace=15}#1}}
\renewcommand\smallcapsspacing[1]{{\addfontfeature{LetterSpace=10}#1}}
}{}
\makeatother
\fi
% graphix
\usepackage{graphicx}
\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}
% booktabs
\usepackage{booktabs}
% url
\usepackage{url}
% hyperref
\usepackage{hyperref}
% units.
\usepackage{units}
\setcounter{secnumdepth}{-1}
% citations
\usepackage{natbib}
\bibliographystyle{plainnat}
% pandoc syntax highlighting
% table with pandoc
\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
% multiplecol
\usepackage{multicol}
% strikeout
\usepackage[normalem]{ulem}
% morefloats
\usepackage{morefloats}
% tightlist macro required by pandoc >= 1.14
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
% title / author / date
\title{A Minimal Book Example}
\author{Author Name}
\date{2021-12-22}
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\maketitle
{
\setcounter{tocdepth}{2}
\tableofcontents
}
\hypertarget{table}{%
\chapter{Table}\label{table}}
\begin{longtable}[]{@{}
>{\raggedright\arraybackslash}p{(\columnwidth - 10\tabcolsep) * \real{0.04}}
>{\raggedright\arraybackslash}p{(\columnwidth - 10\tabcolsep) * \real{0.20}}
>{\raggedright\arraybackslash}p{(\columnwidth - 10\tabcolsep) * \real{0.20}}
>{\raggedright\arraybackslash}p{(\columnwidth - 10\tabcolsep) * \real{0.24}}
>{\raggedright\arraybackslash}p{(\columnwidth - 10\tabcolsep) * \real{0.18}}
>{\raggedright\arraybackslash}p{(\columnwidth - 10\tabcolsep) * \real{0.13}}@{}}
\toprule
Properties & Dobutamine & Isoprenaline & Ephedrine & Metaraminol & Phenylephrine \\
\midrule
\endhead
Uses & Stress testing, increasing CO & Severe bradycardia & ↑ SVR without ↓ in HR & ↑ SVR & ↑ SVR \\
Dosing & 5-15µg/kg/min & Infusion from 0.5-10µg/min & 3-6mg bolus & Bolus 0.5-2mg & Bolus start at 50-100mcg \\
Route & IV & IV & IV & IV & IV/IM/SC \\
Presentation & Racemic mixture of 250mg dobutamine in 20ml water & Clear solution at 1mg/ml & Clear, colourless solution in 30mg/ml ampoule & Clear, colourless solution in ampoule at 10mg/ml, typically reconstituted to 0.5mg/ml & Clear, colourless solution at 100mcg/ml \\
Absorption & IV & IV & IV or IM & IV & IV \\
Metabolism & t1/2 2-5 min. COMT to inactive metabolites. & Hepatic by COMT & Hepatic (not metabolised by MAO and COMT), giving a longer (10-60 minute) duration of action and a t1/2β of 3-6 hours & Some uptake into adrenergic nerve endings & Hepatic by MAO \\
Elimination & Urinary excretion of unchanged drug and metabolites & 50\% unchanged in urine & Renal of metabolites, t1/2β 2-3 hours & & \\
Mechanism of action & β1\textgreater\textgreater β2, D2 & β1\textgreater β2 & ↑ NA release (indirect α1) and direct α and β agonism & Direct and indirect (via ↑ NA release) α1 agonism & Direct α1 \\
Respiratory & Bronchodilation & Potent bronchodilation & Bronchodilation & & \\
CVS & ↑ HR, CO, contractility, and automaticity. Β2 effects may ↓ SVR and BP, particularly if ↓ preload. & ↑ HR and ↑ CO, modest ↑ inotropy. ↓ SVR due to β2 effects but BP usually unchanged due to ↑ CO. & Direct and indirect (via NA release) ↑ in HR, BP, and CO. Arrhythmogenic. & ↑ SVR/PVR, reflex bradycardia. Indirect ↑ in coronary flow. & ↑ SVR and BP, potential reflex bradycardia. Not arrhythmogenic. \\
CNS & Tremor & & ↑ MAC, mydriasis. & & \\
MSK & & & & & \\
Renal & ↑ RBF and ↑ urinary output with no improvement in renal function & & ↓ RBF & ↓ RBF & ↓ RBF \\
Metabolic & & & & & \\
GU & & & & ↓ Uterine blood flow & ↓ Uterine blood flow \\
GIT & & & & & \\
\bottomrule
\end{longtable}
\end{document}