0

I have a threeparttable in a memoir document that I would like to at most stretch from the text block's inner margin to the outer margin of the margin notes. I would further like for the table to start at the inner margin on odd numbered pages and end at the inner margin on odd numbered pages.

I thought that combination of tabulary and floatrow would give me this and thusly I concocted the following, which sadly does not at all what I want. It is clear that the tables do not start where I would like them to. I suspect that the width is also wrong. And, perhaps least apparent, the caption of the second table does not appear to have the same width as its table.

What should I be doing instead? I have tried reading the floatrow documentation, but it is pretty quiet on the subject.

\documentclass[twoside]{memoir}
\usepackage{showframe}
\usepackage{threeparttable}
\let\newfloat\undefined% [Fix error loading `floatrow` with `memoir`](https://tex.stackexchange.com/a/246918/71332)
\usepackage{floatrow}
\usepackage{calc}
\newlength{\maxfloatwidth}
\setlength{\maxfloatwidth}{\textwidth+\marginparsep+\marginparwidth}% Ought to be the length from the text block's inner margin to the outer margin of the margin notes
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{blindtext}

\begin{document} \Blindtext[3] \thisfloatsetup{margins=hangoutside} \begin{table}[t] \begin{floatrow} \ttabbox{\caption{A table heading that goes on and on and on and on and on and on and on and on and on and on}}{\begin{threeparttable} \begin{tabulary}{\maxfloatwidth}{@{} L c c c @{}} \toprule A & B & C & D \tabularnewline \midrule a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline \bottomrule \end{tabulary} \begin{tablenotes} \item[a] \blindtext \end{tablenotes} \end{threeparttable}} \end{floatrow} \end{table} \Blindtext[5] \thisfloatsetup{margins=hangoutside} \begin{table}[t] \begin{floatrow} \ttabbox{\caption{A table heading that goes on and on and on and on and on and on and on and on and on and on}}{\begin{threeparttable} \begin{tabulary}{1.2\linewidth}{@{} L c c c @{}} \toprule A & B & C & D \tabularnewline \midrule a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline \bottomrule \end{tabulary} \begin{tablenotes} \item[a] \blindtext \end{tablenotes} \end{threeparttable}} \end{floatrow} \end{table} \Blindtext[5] \end{document}

Table on even-numbered page

Table on odd-numbered page

Fredrik P
  • 1,386

3 Answers3

2

Here is a solution using adjustwidth*. Note there is no need to use the calc package anymore. And memoir has something similar to showframe build in.

\documentclass[twoside]{memoir}
\usepackage{threeparttable}
\newlength{\maxfloatwidth}
\setlength{\maxfloatwidth}{\dimexpr\textwidth+\marginparsep+\marginparwidth}% 
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{blindtext}

\pagestyle{showlocs} % similar to showframe

%\strictpagecheck

\begin{document} \Blindtext[3] \begin{table}[t] \begin{adjustwidth}{0pt}{\dimexpr-\marginparsep-\marginparwidth\relax} \begin{threeparttable} \caption{A table heading that goes on and on and on and on and on and on and on and on and on and on} \begin{tabulary}{\maxfloatwidth}{@{} L c c c @{}} \toprule A & B & C & D \tabularnewline \midrule a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline \bottomrule \end{tabulary} \begin{tablenotes} \item[a] \blindtext \end{tablenotes} \end{threeparttable} \end{adjustwidth} \end{table} \Blindtext[5] \begin{table}[t] \begin{adjustwidth}{0pt}{\dimexpr-\marginparsep-\marginparwidth\relax} \begin{threeparttable} \caption{A table heading that goes on and on and on and on and on and on and on and on and on and on} \begin{tabulary}{\maxfloatwidth}{@{} L c c c @{}} \toprule A & B & C & D \tabularnewline \midrule a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline \bottomrule \end{tabulary} \begin{tablenotes} \item[a] \blindtext \end{tablenotes} \end{threeparttable} \end{adjustwidth} \end{table} \Blindtext[5] \end{document}

daleif
  • 54,450
  • Strange. Even though the adjustwidth* environment is used, the floats extend into the right margin irrespective of its placed on an odd or even page. (This is clearer with showframe :-D) – Fredrik P Sep 27 '23 at 14:05
  • 1
    See the commented line – daleif Sep 27 '23 at 14:09
  • Wohoo! Thanks :-) But why did you comment it in the first place…? – Fredrik P Sep 27 '23 at 14:12
  • My only complaint is that it isn't responsive for even numbered pages. It works when the table is really \maxfloatwidth wide, but my intention was that that was just a maximum. When the table is narrower than that, then the table is too far to the left. That is, it start at the outer margin of the margin notes and ends before the inner margin of the text block, whereas I'm after the opposite. – Fredrik P Sep 27 '23 at 15:22
  • That was not specified. Add \ifoddpage\raggedright\else\raggedleft\fi as the first thing inside the adjustwidth – daleif Sep 27 '23 at 15:39
  • Thanks! I thought that it was implied when I specified how long the width should be "at most". I guess that I should've added fewer a's in the leftmost cells... But then there probably would've been objections for why I couldn't just use a plain old tabular instead of tabulary. It seems I can never be clear enough when I post questions involving tabulary... – Fredrik P Sep 27 '23 at 16:23
1

Quite similar to nice @daleif answer (+1), but instead of threeparttable and tabulary packages I would rather use talltblr of tabularray package. Using it the table code is shorter and table looks a wee bit nicer:

\documentclass[twoside]{memoir}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\usepackage{lipsum} \pagestyle{showlocs} % similar to showframe \strictpagecheck % <---

\begin{document} \chapter{Very important chapter} \lipsum[1-3] \section{Section with wide table} \lipsum[4]

\begin{table}[ht] \begin{adjustwidth}{0pt}{-\dimexpr\marginparsep+\marginparwidth\relax} \begin{talltblr}[ caption = {A table heading that goes on and on and on and on and on and on and on and on and on and on}, label = {tab:talltblr}, note{a} = {\lipsum[66]}, ]{colspec = {@{} X[j] c c c @{}}} \toprule A & B & C & D \ \midrule a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \ a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \ \bottomrule \end{talltblr} \end{adjustwidth} \end{table} \lipsum[5] \end{document}

enter image description here

Zarko
  • 296,517
  • Nice! (+1) But surely tabularray hasn’t yet been updated so that it can replace tabulary? https://github.com/lvjr/tabularray/discussions/397 – Fredrik P Sep 27 '23 at 14:21
  • @FredrikP, I don't see, why in your case the tabulary should be used. The same result you get with tabularx table or as I suggested by temporary version of the tabularray package. As package author ones noted, next version of package will appear soon. It may introduce support "tabulary" (which you can already imitate as is shown in link you provide). – Zarko Sep 27 '23 at 15:13
  • The table in the example is not the one that I have in my actual document :-) I guess that I should’ve added fewer a’s in the leftmost cells… Also, I’ve tried the code that allegedly imitates tabulary. It doesn’t. See https://tex.stackexchange.com/questions/683538/replicate-tabularys-l-column-with-tabularray – Fredrik P Sep 27 '23 at 16:03
  • @FredrikP, I said that in your particular case shown in you question there is no difference between tabulary and tabularx table. . For other tables we haven't any information here. As I see, You got nice solution with use of tabulary package. Stick with it! – Zarko Sep 27 '23 at 17:18
0

I'm not sure why using floatrow. If your aim is that such big floats on odd numbered pages stick on the right and the opposite on even numbered pages, you can use adjustwidth (that's built-in in memoir).

\documentclass[twoside]{memoir}
\usepackage{threeparttable}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{ifoddpage}

\usepackage{blindtext} \usepackage{showframe}

\begin{document}

\Blindtext[3]

\begin{table}[htp] \checkoddpage

\begin{adjustwidth} {-\ifoddpage 0pt\else\dimeval{\marginparsep+\marginparwidth}\fi} {-\ifoddpage\dimeval{\marginparsep+\marginparwidth}\else 0pt\fi}

\begin{threeparttable} \caption{A table heading that goes on and on and on and on and on and on and on and on and on and on}

\begin{tabularx}{\dimeval{\textwidth+\marginparsep+\marginparwidth}}{@{} X c c c @{}} \toprule A & B & C & D \tabularnewline \midrule a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline \bottomrule \end{tabularx} \begin{tablenotes} \item[a] \blindtext \end{tablenotes} \end{threeparttable}

\end{adjustwidth}

\end{table}

\Blindtext[5]

\begin{table}[htp] \checkoddpage

\begin{adjustwidth} {-\ifoddpage 0pt\else\dimeval{\marginparsep+\marginparwidth}\fi} {-\ifoddpage\dimeval{\marginparsep+\marginparwidth}\else 0pt\fi}

\begin{threeparttable} \caption{A table heading that goes on and on and on and on and on and on and on and on and on and on}

\begin{tabularx}{\dimeval{\textwidth+\marginparsep+\marginparwidth}}{@{} X c c c @{}} \toprule A & B & C & D \tabularnewline \midrule a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a & 123 & 456 & 789 \tabularnewline \bottomrule \end{tabularx} \begin{tablenotes} \item[a] \blindtext \end{tablenotes} \end{threeparttable}

\end{adjustwidth}

\end{table}

\Blindtext[5]

\end{document}

enter image description here

No need for tabulary either.

egreg
  • 1,121,712