Replies: 3 comments 6 replies
-
I think this is impossible: the widths of |
Beta Was this translation helpful? Give feedback.
1 reply
-
\documentclass{article}
\usepackage[showframe, twoside, paperheight=6cm]{geometry}
\usepackage{tabularray}
\usepackage{xcolor}
\usepackage{changepage}
\ExplSyntaxOn
\cs_undefine:N \__tblr_halign_whole:Nn
\cs_new_protected:Npn \__tblr_halign_whole:Nn #1#2
{
\__tblr_check_odd_page:
\use:e
{
\__tblr_halign_whole_aux:Nnn #1
\__tblr_toggle_left_right:nn
{
\str_if_eq:nnT {#2} {l} { \hfil }
\str_if_eq:nnT {#2} {l-hss} { \hss }
}
{
\str_if_eq:nnT {#2} {r} { \hfil }
\str_if_eq:nnT {#2} {r-hss} { \hss }
}
}
}
\cs_new_protected:Npn \__tblr_halign_whole_aux:Nnn #1#2#3
{
\noindent
% why not use \__tblr_prop_item:nn { inner } { width }?
\hbox_to_wd:nn { \linewidth }
{
#2
\box_use:N #1
#3
}
}
\cs_new_protected:Npn \__tblr_check_odd_page: {}
% named after "/tcb/toggle left and right" key from tcolorbox
\cs_new:Npn \__tblr_toggle_left_right:nn #1#2 { {#1} {#2} }
% pity, file hooks like "package/<pkgname>/after" are not one-time hooks
\hook_gput_code:nnn { begindocument } { tblr }
{
\IfPackageLoadedTF {changepage}
{
\cs_gset_protected:Npn \__tblr_check_odd_page:
{
\checkoddpage
}
\cs_gset:Npn \__tblr_toggle_left_right:nn #1#2
{
\bool_lazy_all:nTF
{
{ \l__tblr_toggle_left_right_bool }
{ \legacy_if_p:n { @twoside } } % \if@twoside
{ ! \legacy_if_p:n { oddpage } } % \ifoddpage from changepage pkg
}
{ {#2} {#1} }
{ {#1} {#2} }
}
}
{}
}
% glue code for https://github.com/muzimuzhi/tabularray-dev
\keys_if_exist:nnTF { tblr/__outer } { halign }
{ \keys_define:nn { tblr/__outer} }
{ \keys_define:nn { tblr/outer } }
{
toggle-left-and-right .bool_set:N = \l__tblr_toggle_left_right_bool
, toggle-left-and-right .default:n = true
}
\ExplSyntaxOff
\begin{document}
\begin{longtblr}[
% outer option "halign" is undocumented!
% new value "r-hss": ragged right using \hss
halign=r-hss,
toggle-left-and-right
]{
hlines={blue}, vlines={blue},
colspec={XX},
width=\linewidth+\marginparsep+\marginparwidth
}
a & a \\
b & b \\
c & c \\
d & d \\
e & e \\
f & f \\
g & g
\end{longtblr}
\end{document} |
Beta Was this translation helpful? Give feedback.
4 replies
-
That works great, thank you – see attached. I'll be sure to acknowledge you both work in the final version of the book, if that is ok. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In a textbook I'm contributing to, there's a wide outer margin for notes. Many of my tables are longtblr and use the full pagewidth as they have many columns.
On odd pages, the tables extend into the margin, but on even pages they do not. This is expected as the even page margin is on the right and the tables span left to right (see below and screenshot).
even |odd
| margin | text.................................................| binding |..................................................text | margin |
I'd like (an option for) long tables that start on an even/odd page and break onto an odd/even page to span the pagewidth.
I've been playing with redefining the \TblrNewPage as a "hook" to make this happen, but haven't been successful.
Beta Was this translation helpful? Give feedback.
All reactions