我正在为备忘单做一些表格。
我的目标是制作一个具有文本大小\tiny
(或更小......)的表格,以便表格(\usepackage{nicematrix}
)适合width = 0.23\textwidth
宽列。
这是我的代码:
\documentclass[]{article}
\usepackage[landscape]{geometry}
\usepackage[dvipsnames, table,x11names]{xcolor}
\definecolor{mintbg}{rgb}{.63,.79,.95}
\colorlet{lightmintbg}{mintbg!40}
\usepackage{booktabs}
\usepackage{nicematrix,tikz}
\usepackage{paracol}
\usepackage{parskip} % paragraph layouts
\usepackage{fancyheadings}
\begin{document}
%----------------------------------------------------------------------------------------------
\pagestyle{fancy}
\rfoot{Seite \thepage}
\rhead{Cheat sheet }
\lhead{}
\fancyheadoffset{0.01 cm}
\renewcommand{\footrulewidth}{0.4pt}
\newgeometry{top=0.55in,bottom=0.55in,right=0.3in,left=0.3in}
\begin{paracol}{4}
\begin{small}
\begin{table}
\tiny
\begin{NiceTabular*}{0.3\textwidth}{@{}>{\tiny}c*{3}{@{\extracolsep{\fill}}c}@{}}[colortbl-like]
\toprule
\bfseries Ziel & \bfseries indirekte Hemmung & \bfseries Wirkstoff & \bfseries Applikation\\
\midrule
\rowcolor{lightmintbg}\Block{4-1}{AT-III}& F-X \& F-II & unfrakt. Heparin & s.c. / i.v.\\
\rowcolor{lightmintbg}& F-X $>$ F-II & niedermolek. Heparin & s.c. / i.v.\\
\rowcolor{lightmintbg}& F-X $>>$ F-II & Herparinoide &\Block{}{ s.c. / \\ lokal (Salbe)}\\
\rowcolor{lightmintbg}& F-X & Fondaparinux& s.c.\\
\midrule
\Block{}{Vit. K Epoxid\\-Reduktase} & F-II, VII, IX, X & Cumarine & oral\\
\midrule
\rowcolor{lightmintbg}\Block{2-1}{F-X}&-& \Block{}{ Rivaroxaban,\\ Apixaban, \\Edoxaban }& oral\\
\rowcolor{lightmintbg}&- &Hirudin & i.v.\\
\bottomrule
\CodeAfter
\end{NiceTabular*}
\end{table}
\end{small}
\end{paracol}
\end{document}
正如我所使用的,\usperpackage{nicematrix}
你可能需要下载最新版本的 trunk(或者你怎么称呼它 :) ) =>www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
答案1
我认为这张表更接近你的目标。
完成nicematrix
,正常字体并缩小到0.25\textwidth
\documentclass[]{article}
\usepackage[landscape,showframe]{geometry}
\usepackage[dvipsnames, table,x11names]{xcolor}
\definecolor{mintbg}{rgb}{.63,.79,.95}
\colorlet{lightmintbg}{mintbg!40}
\usepackage{booktabs}
\usepackage{nicematrix,tikz}
\begin{document}
\begin{table}
\sffamily
\setlength{\tabcolsep}{2pt}
\resizebox{0.25\textwidth}{!}{% resize to 0.25\textwidth <<<<<<
\begin{NiceTabular}{ *{4}{l} @{}}[hvlines, cell-space-limits=4pt,
rules/color={white},rules/width=0.5pt,
code-before= {\rowcolors{2}{lightmintbg}{gray!10}[cols=1-4,restart]},
code-before= {\rectanglecolor{gray!25}{1-1}{1-4}}, % header row: \rectanglecolor{<color>}{<row ini-col ini>}{<row end-col end>} <<<<
]
\bfseries Ziel & \bfseries indirekte Hemmung & \bfseries Wirkstoff & \bfseries Applikation \\
\Block[fill=lightmintbg]{4-1}{AT-III}& F-X und F-II & unfraktionierites Heparin & s.c., i.v. \\
& F-X $>$ F-II & niedermolekulares Heparin & s.c., i.v. \\
& F-X $>>$ F-II & Herparinoide & s.c., lokal (Salbe) \\
& F-X & Fondaparinux & s.c. \\
\Block{}{Vit.-K-Epoxid--Reduktase} & F-II, VII, IX, X & Cumarine & oral \\
F-II & & Debigatran & oral \\
\Block[l, fill=lightmintbg]{2-2}{F-X}& & Rivaroxaban, Apixaban, Edoxaban & oral \\
& &Hirudin & i.v. \\
\end{NiceTabular}
}
\end{table}
\end{document}
答案2
假设您确实想要获得一个横向页面,则可以使用以下代码将整个表格挤压到 4 个可用列之一中:
\documentclass[landscape]{article}
\usepackage{geometry}
\usepackage[dvipsnames, table,x11names]{xcolor}
\definecolor{mintbg}{rgb}{.63,.79,.95}
\colorlet{lightmintbg}{mintbg!40}
\usepackage{paracol}
\usepackage{parskip} % paragraph layouts
\usepackage{fancyhdr}
\usepackage{booktabs}
\usepackage{nicematrix,tikz}
\usepackage{calc}
\pagestyle{fancy}
\rfoot{Seite \thepage}
\rhead{Cheat sheet }
\lhead{}
\fancyheadoffset{0.01 cm}
\renewcommand{\footrulewidth}{0.4pt}
\newgeometry{top=0.55in,bottom=0.55in,right=0.3in,left=0.3in}
\newlength{\firstcolwidth}
\setlength{\firstcolwidth}{\widthof{\tiny Reduktase}}
\newlength{\secondcolwidth}
\setlength{\secondcolwidth}{\widthof{\tiny F-X $>>$ F-II}}
\newlength{\thirdcolwidth}
\setlength{\thirdcolwidth}{\widthof{\tiny Fondaparinux}}
\newlength{\lastcolwidth}
\setlength{\lastcolwidth}{\widthof{\tiny s.c. / lokal}}
\newcolumntype{Y}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{paracol}{4}
\begin{table}
\tiny
\setlength{\tabcolsep}{0pt}
\begin{NiceTabular*}{0.24\textwidth}{@{\extracolsep{\fill}}
Y{\firstcolwidth}
Y{\secondcolwidth}
Y{\thirdcolwidth}
Y{\lastcolwidth}}
\CodeBefore
\rowcolors{1}{lightmintbg}{}[respect-blocks]
\Body
\toprule
\bfseries Ziel & \bfseries ind. Hemmung & \bfseries Wirkstoff & \bfseries Appl.\\
\midrule
\Block{4-1}{AT-III} & F-X \& F-II & unfrakt. Heparin & s.c. / i.v.\\
& F-X $>$ F-II & niedermolek. Heparin & s.c. / i.v.\\
& F-X $>>$ F-II & Herparinoide & s.c. / lokal (Salbe)\\
& F-X & Fondaparinux & s.c.\\
\midrule
Vit. K Epoxid-Reduktase & F-II, VII, IX, X & Cumarine & oral\\
\midrule
\Block{2-1}{F-X} & - & Rivaroxaban, Apixaban, Edoxaban & oral\\
& - & Hirudin & i.v.\\
\bottomrule
\end{NiceTabular*}
\end{table}
\end{paracol}
\end{document}
要将表格压缩到纵向页面的 4 列之一中,您可以使用\setlength{\lastcolwidth}{\widthof{\tiny (Salbe)}}
MWE 中的定义并将其添加\setlength\columnsep{0.013\textwidth}
到文档的序言中。