Problem & MWE
I would like to add a simple tabular table (as described in Overleaf), inside a longtblr table (as proposed/built up by @CarLaTeX in another stack exchange question).
As shown in the following MWE and in the corresponding figure, where I added the simple tabular table (as indicated in Overleaf) inside my longtblr table, we can notice that:
- the black lines forming the tabular table are not shown, and
- the longtblr table is not centered anymore.
% The original "longtblr" table was created by @CarLaTeX in
% https://tex.stackexchange.com/questions/675559/how-to-draw-horizontal-rules-lines-beginning-in-column-i-and-ending-in-column-j
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{light-gray}{HTML}{FFFFFF}
\definecolor{light-blue}{HTML}{EBF5FB}
\usepackage{tabularray}
\title{}
\author{}
\begin{document}
\maketitle
\begin{longtblr}[
caption = {This is a caption.},
]{
colspec={m{1.2cm} m{0.5cm} m{1cm} m{1.5cm} m{1.5cm} m{4cm} m{1.5cm}},
row{1}={font=\itshape},
row{2,5-7}={bg=light-blue},
row{3-4}={bg=light-gray},
hlines
}
& Day
& Month
& Hours
& Feature 1
& Feature 2
& Feature 3\\
%-------------------------------------------------
Friday
& 5
& June
&
& A\textsubscript{1}
& % A\textsubscript{2}
\begin{center}
\begin{tabular}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tabular}
\end{center}
& A\textsubscript{3}
\\
%-------------------------------------------------
\SetCell[r=2]{l} Saturday
& \SetCell[r=2]{l} 6
& \SetCell[r=2]{l} June
& 14 -- 21
& B\textsubscript{1}
&
& B\textsubscript{3}
\\
&
&
&
& C\textsubscript{1}
& C\textsubscript{2}
& C\textsubscript{3}
\\
% -------------------------------------------------
\SetCell[r=3]{l} Sunday
& \SetCell[r=3]{l} 7
& \SetCell[r=3]{l} June
& 08 -- 10
& D\textsubscript{1}
& D\textsubscript{2}
& D\textsubscript{3}
\\
&
&
& 10 -- 17
& E\textsubscript{1}
&
& E\textsubscript{3}
\\
&
&
&
& F\textsubscript{1}
& F\textsubscript{2}
& F\textsubscript{3}
\\
% -------------------------------------------------
\end{longtblr}
\end{document}
Questions
Just by adding that simple tabular table, as shown in Overleaf, inside my longtblr table, we can see that the black lines forming the tabular table are not shown. Also the longtblr table is not centered anymore.
- How can I show the black lines forming the tabular table?
- How can I re-center the entire longtblr table?
Desired Output for the "tabular" table inside the "longtblr" table.
The "tabular" table should have borders as shown here:
1st Editing, after the @Jasper Habicht answer
Hello @Jasper Habicht, by using your solution, I have noticed that, if I add some text before and after the tblr environment,
\begin{tblr}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tblr}
the text in the other columns (but in the same row) goes up to the top of the row, i.e. is not vertically aligned as before. In addition, in the same column where there is now the tblr table, I can see some empty space at the bottom of the row, I mean before reaching the \hline, i.e. under my text which is just below the tblr table...
Please see here below the MWE and the corresponding figure:
\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{light-gray}{HTML}{FFFFFF}
\definecolor{light-blue}{HTML}{EBF5FB}
\usepackage{tabularray}
\begin{document}
{\centering Centered Text\par}
\begin{longtblr}[
caption = {This is a caption.},
]{
colspec={m{1.2cm} m{0.5cm} m{1cm} m{1cm} m{1.5cm} m{3.5cm} m{1.5cm}},
cells={font=\small},
row{1}={font=\itshape\small},
row{2,5-7}={bg=light-blue},
row{3-4}={bg=light-gray},
hlines
}
& Day
& Month
& Hours
& Feature 1
& Feature 2
& Feature 3\\
%-------------------------------------------------
Friday
& 5
& June
&
& A\textsubscript{1}
& This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times.
\begin{tblr}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tblr}
This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times.
& A\textsubscript{3}
\\
%-------------------------------------------------
\SetCell[r=2]{l} Saturday
& \SetCell[r=2]{l} 6
& \SetCell[r=2]{l} June
& 14 -- 21
& B\textsubscript{1}
&
& B\textsubscript{3}
\\
&
&
&
& C\textsubscript{1}
& C\textsubscript{2}
& C\textsubscript{3}
\\
% -------------------------------------------------
\SetCell[r=3]{l} Sunday
& \SetCell[r=3]{l} 7
& \SetCell[r=3]{l} June
& 08 -- 10
& D\textsubscript{1}
& D\textsubscript{2}
& D\textsubscript{3}
\\
&
&
& 10 -- 17
& E\textsubscript{1}
&
& E\textsubscript{3}
\\
&
&
&
& F\textsubscript{1}
& F\textsubscript{2}
& F\textsubscript{3}
\\
% -------------------------------------------------
\end{longtblr}
\end{document}
2nd Editing
I have just copied and pasted
column{6}={preto={\begin{minipage}{3.5cm}}, appto={\end{minipage}}}
here:
\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage[dvipsnames,table]{xcolor}
\definecolor{light-gray}{HTML}{FFFFFF}
\definecolor{light-blue}{HTML}{EBF5FB}
\usepackage{tabularray}
\begin{document}
{\centering Centered Text\par}
\begin{longtblr}[
caption = {This is a caption.},
]{
colspec={m{1.2cm} m{0.5cm} m{1cm} m{1cm} m{1.5cm} m{3.5cm} m{1.5cm}},
cells={font=\small},
row{1}={font=\itshape\small},
row{2,5-7}={bg=light-blue},
row{3-4}={bg=light-gray},
column{6}={preto={\begin{minipage}{3.5cm}}, appto={\end{minipage}}}
hlines
}
& Day
& Month
& Hours
& Feature 1
& Feature 2
& Feature 3\\
%-------------------------------------------------
Friday
& 5
& June
&
& A\textsubscript{1}
& This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times.
\begin{tblr}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tblr}
This is a long text that will be repeated many times. This is a long text that will be repeated many times. This is a long text that will be repeated many times.
& A\textsubscript{3}
\\
%-------------------------------------------------
\SetCell[r=2]{l} Saturday
& \SetCell[r=2]{l} 6
& \SetCell[r=2]{l} June
& 14 -- 21
& B\textsubscript{1}
&
& B\textsubscript{3}
\\
&
&
&
& C\textsubscript{1}
& C\textsubscript{2}
& C\textsubscript{3}
\\
% -------------------------------------------------
\SetCell[r=3]{l} Sunday
& \SetCell[r=3]{l} 7
& \SetCell[r=3]{l} June
& 08 -- 10
& D\textsubscript{1}
& D\textsubscript{2}
& D\textsubscript{3}
\\
&
&
& 10 -- 17
& E\textsubscript{1}
&
& E\textsubscript{3}
\\
&
&
&
& F\textsubscript{1}
& F\textsubscript{2}
& F\textsubscript{3}
\\
% -------------------------------------------------
\end{longtblr}
\end{document}
But I got this:
3rd Editing
By replacing this command
column{6}={preto={\begin{minipage}{3.5cm}}, appto={\end{minipage}}}
with this one,
column{6}={preto={\minipage{3.5cm}}, appto={\endminipage}},
all the warnings disappear!
Many thanks @Jasper Habicht!







minipagefor instance). – Jasper Habicht Feb 28 '23 at 18:28minipage, many thanks!! :-) – Ommo Feb 28 '23 at 18:33column{6}={preto={\begin{minipage}{3.5cm}}, appto={\end{minipage}}}, I guess. – Jasper Habicht Feb 28 '23 at 18:35pretoandappto, in your previous comment, just gives me an error.... Also, I got many errors when I tried to use the\begin{minipage},\end{minipage}environment.... :-) – Ommo Feb 28 '23 at 18:44column{6}={preto={\begin{minipage}{3.5cm}}, appto={\end{minipage}}}in my question... at the end.. – Ommo Feb 28 '23 at 18:53Should I delete my edited parts in my question ??
– Ommo Feb 28 '23 at 18:56\begin{minipage}{3.5cm}by\minipage{3.5cm}and\end{minipage}by\endminipageif you find these warnings too annoying. Also note that you are missing a comma before the last option (hlines). – Jasper Habicht Feb 28 '23 at 19:54column{6}={preto={\minipage{3.5cm}}, appto={\minipage}},:-) – Ommo Mar 01 '23 at 09:20end... I used this one:column{6}={preto={\minipage{3.5cm}}, appto={\endminipage}},:-) – Ommo Mar 01 '23 at 09:31