Skip to content

Commit

Permalink
Replace array with tabularray and update
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Muirhead authored Oct 16, 2023
1 parent b3921af commit d7f7c7a
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 43 deletions.
42 changes: 28 additions & 14 deletions uqspace-article.sty
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

\ProvidesExplPackage
{uqspace-article} % - Name
{2022/12/17} % - Date
{2.0.0} % - Version
{2023/10/16} % - Date
{2.1.0} % - Version
{Article class for use by UQ Space} % - Description

%% ============================================================================
Expand Down Expand Up @@ -154,7 +154,7 @@

%% ----------------------------------------------------------------------------

% --- Set the numbering of sections to
% --- Set the numbering of sections to
% Sections -> I, II, III, ...
% Sub-sections -> A, B, C, ...
% Sub-sub-sections -> i, ii, iii, ...
Expand Down Expand Up @@ -245,35 +245,35 @@
%% ----------------------------------------------------------------------------

\RenewDocumentCommand \maketitle { } {

\thispagestyle { title }

\begin{tikzpicture}[ remember~picture, overlay ]
% Tweak the UQ Purple to produce the "dark sky" effect
\colorlet { uq purple }{ uq purple!60!black }

\node ( banner ) at ([ yshift=-2mm ] current~page . north ) [
anchor = north, fill = uq purple,
minimum~width = ( \paperwidth-4mm ), minimum~height = 36mm,
minimum~width = ( \paperwidth-4mm ), minimum~height = 36mm,
] {};

\node at ( banner . center ) {
{ \transparent{ 0.45 } \includesvg[ width=\paperwidth, inkscapearea=page ]{ images/starheader.svg } }
};

\shade [ shading=uq gradient east, path~fading=west ] ( banner . north~west ) rectangle ( banner . south~east );

\begin { scope }[ outer~sep = 6mm ]
% UQ Space Logo
\node [ anchor=west ] at ( banner . west ){ \includesvg [ height=20mm ]{ packages/uqspace-logo.svg } };
% Title Block
\node [ anchor=east ] at ( banner . east ){ \parbox { 0.6\linewidth }{
\sffamily \raggedleft \large \color { white }
\projectTag \\
\node [ anchor=east ] at ( banner . east ){ \parbox { 0.6\linewidth }{
\sffamily \raggedleft \large \color { white }
\projectTag \\
\The{authors}
} };
\end { scope }

\end{tikzpicture}

% Very much a heuristic measurement
Expand Down Expand Up @@ -302,6 +302,20 @@
\AtBeginEnvironment { tabular } \small


% --- Set style for table headings

\DeclareDocumentCommand \theadfont { }{ \itshape }


% --- Set default colour for table rules

\pretocmd \tblr_set_hline:nnn {
\tl_if_empty:NT \l__tblr_hline_fg_tl {
\tl_set:Nn \l__tblr_hline_fg_tl { uq purple }
}
}{ }{ }


% --- Reduction of spacing after tables and figures

\AfterEndEnvironment { table } { \vspace { -2ex } }
Expand Down
81 changes: 54 additions & 27 deletions uqspace-preamble.sty
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

\ProvidesExplPackage
{uqspace-preamble} % - Name
{2022/10/04} % - Date
{1.1.1} % - Version
{2023/10/16} % - Date
{2.0.0} % - Version
{Report preamble list for use by UQ Space} % - Description

%% ============================================================================
Expand Down Expand Up @@ -195,33 +195,49 @@

%% ============================== Table packages ==============================

\RequirePackage { array } % For customisation of tables
\RequirePackage { booktabs } % Horizontal rules in tables
\RequirePackage { multirow }
\RequirePackage { makecell } % Robust table cells -> e.g. \makecell
% ~ Allows for line-breaks within cells
% ~ Use \thead{...} for column names

\RequirePackage { tabularray } % Replaces `array' as the default table
% Contains a *lot* of functionality, and
% makes the `makecell' package redundant

\RequirePackage { rotating } % Rotate cells with \begin{sideways}...
\RequirePackage { longtable } % Tables that go over multiple pages
\RequirePackage { threeparttable } % Tables that allow for notes below
\RequirePackage { tablefootnote } % Allows for footnotes within tables

%% ------------------------------ Table commands ------------------------------

\robustify \thead
\renewcommand \theadfont { \itshape }
\renewcommand \arraystretch { 1.2 } % Spread rows out by 20%

\newcolumntype { C }[ 1 ]{ >{ \Centering\arraybackslash } m { #1 } }
\newcolumntype { R }[ 1 ]{ >{ \RaggedLeft\arraybackslash } m { #1 } }
\newcolumntype { L }[ 1 ]{ >{ \RaggedRight\arraybackslash } m { #1 } }

\newcolumntype { P }[ 1 ]{ >{ \RaggedRight\arraybackslash } p { #1 } }
\newcolumntype { B }[ 1 ]{ >{ \RaggedRight\arraybackslash } b { #1 } }

\newcolumntype { E }[ 1 ]{ >{ \begin{tblEnum} } L { #1 } <{ \end{tblEnum} } }
\newcolumntype { I }[ 1 ]{ >{ \begin{tblItem} } L { #1 } <{ \end{tblItem} } }
% Load libraries from tabularray for easy compatibility.
% Replaces the need for the `booktabs' package.
\UseTblrLibrary { amsmath, booktabs, siunitx }

% Default values for tblr environments
\SetTblrOuter { expand = \thead } % Expand \thead to get cell formats
\SetTblrInner { stretch = 1.2 }

% Simple column defaults for paragraphs
% NOTE: Use h instead of t to get better alignment
\NewColumnType { L }[ 1 ]{ Q[ h, l, #1 ] }
\NewColumnType { R }[ 1 ]{ Q[ h, r, #1 ] }
\NewColumnType { C }[ 1 ]{ Q[ h, c, #1 ] }

% Itemize and Enumerate column types
\NewColumnType { I }[ 2 ][ ]{ Q[ h, l, #2, preto={\begin{softlist}{tblItem}[#1]}, appto=\end{softlist} ] }
\NewColumnType { E }[ 2 ][ ]{ Q[ h, l, #2, preto={\begin{softlist}{tblEnum}[#1]}, appto=\end{softlist} ] }

% Define mock commands for \thead and similar
% NOTE: Must use \newcommand, as \NewExpandableDocumentCommand requires full expansion
\newcommand \thead [ 1 ]{
\SetRow { abovesep = 6pt, belowsep = 6pt }
\SetCell { c, m }
{ \theadfont \theadset #1 }
}
% Defaults only
\newcommand \theadfont { \footnotesize }
\newcommand \theadset { }

% If we wish to override all `tabular` environments to new tblr environment
\RenewDocumentEnvironment { tabular }{ m +b }
{ \begin{tblr}{#1} #2 }
{ \end{tblr} }

%% ============================================================================

Expand Down Expand Up @@ -249,8 +265,6 @@
label =\arabic*.,
labelwidth = 2.5ex,
before* ={\mbox{}\vspace{-\baselineskip}},
before* =\preto\thead{\item[]},
after =\vspace{-\baselineskip}
}

% --- Create itemize for within tables
Expand All @@ -261,8 +275,6 @@
labelwidth = 2.5ex,
label =\textbullet,
before* ={\mbox{}\vspace{-\baselineskip}},
before* =\preto\thead{\item[]},
after =\vspace{-\baselineskip}
}

% --- Create description for List of Acronyms
Expand All @@ -276,6 +288,21 @@
itemindent = 0pt,
}

% --- Create a "soft" list, which only enables if the first token is \item
% Takes the list environment to enable as the first argument
\NewDocumentEnvironment { softlist }{ m O{} +b }{
\bool_set_false:N \l_tmpa_bool
\peek_meaning:NT \item {
\bool_set_true:N \l_tmpa_bool
\begin{#1}[#2]
}
#3
}{
\bool_if:NT \l_tmpa_bool {
\end{#1}
}
}

% \DeclareAcroListStyle { mystyle }{ list }{ list = acronyms }
\acsetup { list/template = description, list/name = Nomenclature }

Expand Down
18 changes: 16 additions & 2 deletions uqspace-style.sty
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

\ProvidesExplPackage
{uqspace-style} % - Name
{2021/03/01} % - Date
{2.3.2} % - Version
{2023/10/16} % - Date
{2.4.0} % - Version
{Styling package for UQ Space Reports} % - Description


Expand Down Expand Up @@ -366,6 +366,20 @@
\AtBeginEnvironment { tabular } \small


% --- Set style for table headings

\DeclareDocumentCommand \theadfont { }{ \itshape }


% --- Set default colour for table rules

\pretocmd \tblr_set_hline:nnn {
\tl_if_empty:NT \l__tblr_hline_fg_tl {
\tl_set:Nn \l__tblr_hline_fg_tl { uq purple }
}
}{ }{ }


% --- Reduction of spacing after tables and figures

\AtEndEnvironment { table }{ \vspace { -2ex } }
Expand Down

0 comments on commit d7f7c7a

Please sign in to comment.