我正在使用 Rmarkdown 编写一本书tufte
,该程序包tufte-latex
用于 pdf 输出。我目前的问题是,我还没有找到一种方法来让表格延伸到比输出的正常边距更宽tufte-latex
。
我尝试过的事情:
- 在环境中包装
table*
(建议这里);但仅适用于长度少于 1 页的表格 - 包装在
fullwidth
环境中;但这对longtable
(见这里) - 使用我的
newgeometry
方法,将表推到新页面上,这是不可取的 \setlength\LTleft
和\setlength\LTright
(这里); 我可以设置其中一个(例如将表格移到右边距),但同时设置两个都不会改变宽度。我认为这是因为列大小是由 Pandoc 固定的吗?
我读过但不明白的内容:
- 重新定义长桌环境这里看起来很有希望,但我不完全明白答案
我能做的事情:
- 我可以使用 Pandoc 过滤器将乳胶输出包装在附加命令或环境包装器中。例如,我有一个过滤器,可以识别宽表并将其放置在布局中
\landscape
(尽管这并不能解决列重叠问题)。 - 我可以更改 Pandoc 使用的乳胶模板,这样我就可以调用其他选项/使用包
主要限制如下:
- 表格可以干净地编译为 html 和 latex;例如,它可以将 markdown 表作为输入,并且不需要明确指定列宽
- 它可以处理长度超过一页的表格
这是由 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}
答案1
所需要做的就是扩展表的列以使用\marginparwidth
和\marginparsep
。
\setlength{\tabcolsep}{6pt} % added to fit in the textwidth<<<<<<<<<<<<<<
\begin{longtable}[]{@{}
>{\raggedright\arraybackslash}p{(\textwidth - 10\tabcolsep) * \real{0.25}}
>{\raggedright\arraybackslash}p{(\textwidth - 10\tabcolsep) * \real{0.25}}
>{\raggedright\arraybackslash}p{(\textwidth - 10\tabcolsep) * \real{0.25}}
>{\raggedright\arraybackslash}p{(\textwidth - 10\tabcolsep) * \real{0.3}}
>{\raggedright\arraybackslash}p{(\textwidth - 10\tabcolsep) * \real{0.3}}
>{\raggedright\arraybackslash}p{(\textwidth - 10\tabcolsep) * \real{0.3}}@{}}
\toprule
第二页用来\usepackage{showframe}
显示页边距。