|
| 1 | +\documentclass{article} |
| 2 | +\usepackage{xcolor} |
| 3 | +\usepackage{tabularray} |
| 4 | +\UseTblrLibrary{booktabs} % Optional, for \toprule etc. |
| 5 | + |
| 6 | +\title{Tables: tblr (with 'article')} |
| 7 | + |
| 8 | +\begin{document} |
| 9 | + |
| 10 | +\maketitle |
| 11 | + |
| 12 | +\section{Basic Usage} |
| 13 | + |
| 14 | +\subsection{A simple table with colspec lcr, textwidth: } |
| 15 | + |
| 16 | +\begin{center} |
| 17 | +\begin{tblr}{ |
| 18 | + colspec = {lcr}, |
| 19 | + rowhead=1, |
| 20 | +} |
| 21 | +%\toprule %% THIS CAUSES COMPILATION TO HANG |
| 22 | +%\hline %% THIS CAUSES COMPILATION TO HANG |
| 23 | +Left aligned & Centered & Right aligned \\ |
| 24 | +% \midrule |
| 25 | +Some text & More text & Final text \\ |
| 26 | +Math $x^2$ & \textbf{Bold text} & \textit{Italic text} \\ |
| 27 | +%\bottomrule |
| 28 | +\end{tblr} |
| 29 | +\end{center} |
| 30 | + |
| 31 | +\subsection{Another table: } |
| 32 | + |
| 33 | +\begin{center} |
| 34 | +\begin{tblr}{ |
| 35 | + width=\linewidth, |
| 36 | + rowhead=1, |
| 37 | + colspec = { |
| 38 | + X[t,l,wd=3cm] % max 3.cm |
| 39 | + Q[t,c] % fixed |
| 40 | + X[t,r,wd=3cm] % max 3cm |
| 41 | + X[t,l] % stretchable |
| 42 | + }, |
| 43 | + row{1} = {font=\bfseries}, |
| 44 | + column{2} = {font=\itshape}, % Italic text in 2nd column |
| 45 | + rowsep = 6pt, |
| 46 | +% hlines, %% THIS CAUSES COMPILATION TO HANG |
| 47 | +% vlines, %% THIS CAUSES COMPILATION TO HANG |
| 48 | +} |
| 49 | +Top aligned, left aligned & Top aligned, centered (italic) & Top aligned, right aligned & Top-left regular \\ |
| 50 | +\SetCell[r=2]{t,l}Multirow: top-left aligned & \SetCell[r=2]{t,c}Multirow: top-centered (italic) & \SetCell[c=2]{t,l}Multicolumn: top-left aligned over 2 cols & \\ |
| 51 | +Bottom aligned, left aligned & Center aligned (italic) & Right aligned & Bottom-left regular \\ |
| 52 | +\end{tblr} |
| 53 | +\end{center} |
| 54 | + |
| 55 | +\subsection{One more table:} |
| 56 | + |
| 57 | +\begin{center} |
| 58 | +\begin{tblr}{ |
| 59 | + colspec = {Q[l] Q[c] Q[r] Q[l]}, % Q = flexible column, with alignment |
| 60 | + rowhead = 1, |
| 61 | + row{1} = {font=\bfseries}, % make header bold |
| 62 | + column{2} = {font=\itshape}, % italicize second column |
| 63 | + column{3} = {halign=center}, % center-align 3rd column |
| 64 | + rowsep = 4pt, |
| 65 | +% hlines, |
| 66 | +% vlines, |
| 67 | +} |
| 68 | +Name & Role & Age & Remarks \\ |
| 69 | +Alice & Developer & 30 & Works remotely \\ |
| 70 | +Bob & Designer & 27 & \SetCell[r=2]{c}On leave \\ |
| 71 | +Charlie & \SetCell[c=2]{l}Intern (UI + UX) & & \\ |
| 72 | +Diana & Project Manager & 34 & Full time \\ |
| 73 | +\end{tblr} |
| 74 | +\end{center} |
| 75 | + |
| 76 | +\subsection{A simple table with colspec X:} |
| 77 | + |
| 78 | +\begin{tblr}{ |
| 79 | + colspec = {X[l]X[c]X[r]}, |
| 80 | +% rowhead=1, |
| 81 | +% width = \textwidth |
| 82 | +} |
| 83 | +%\toprule %% THIS CAUSES COMPILATION TO HANG |
| 84 | +%\hline %% THIS CAUSES COMPILATION TO HANG |
| 85 | +Left aligned & Centered & Right aligned \\ |
| 86 | +% \midrule |
| 87 | +Some text & More text & Final text \\ |
| 88 | +%\bottomrule |
| 89 | +\end{tblr} |
| 90 | + |
| 91 | + |
| 92 | +\end{document} |
0 commit comments