0

I am trying to place two tablex next to each other in my TeXstudio Editor. Luckily, the following post already helped me doing so: stackexchange

But I am having issues with my captions. They do not align with my tables. I use a combination of minigpage and longtables and my result looks like this:

enter image description here

The \centering command won't help out. At some locations I even receive error messages. This is my working code so far (content reduced):

\begin{minipage}[t]{.5\linewidth}
    \centering
    \arrayrulecolor[rgb]{0.753,0.753,0.753}
    \arrayrulecolor[rgb]{0.753,0.753,0.753}
    \begin{longtable}{>{\hspace{0pt}}m{0.18\linewidth}!{\color{black}\vrule}>{\RaggedLeft\hspace{0pt}}m{0.25\linewidth}|>{\RaggedLeft\hspace{0pt}}m{0.25\linewidth}}
        WBP & \multicolumn{1}{>{\hspace{0pt}}m{0.25\linewidth}|}{Min CWT (incl.)} & \multicolumn{1}{>{\hspace{0pt}}m{0.25\linewidth}}{Max CWT (excl.)} \endfirsthead 
        \arrayrulecolor{black}\hline
        MIN & 0 & 6 \\ 
        \arrayrulecolor[rgb]{0.753,0.753,0.753}\hline
        N & 6 & 45 \\ 
        [...] \\
        \hline
        \caption{A}
    \end{longtable}
    \arrayrulecolor{black}
\end{minipage}%
\begin{minipage}[t]{.5\linewidth}
    \centering
    \arrayrulecolor[rgb]{0.753,0.753,0.753}
    \begin{longtable}{>{\hspace{0pt}}m{0.18\linewidth}!{\color{black}\vrule}>{\RaggedLeft\hspace{0pt}}m{0.25\linewidth}|>{\RaggedLeft\hspace{0pt}}m{0.25\linewidth}}
        WBP & \multicolumn{1}{>{\hspace{0pt}}m{0.25\linewidth}|}{Min CWT (incl.)} & \multicolumn{1}{>{\hspace{0pt}}m{0.25\linewidth}}{Max CWT (excl.)} \endfirsthead 
        \arrayrulecolor{black}\hline
        MIN & 0 & 6 \\ 
        \arrayrulecolor[rgb]{0.753,0.753,0.753}\hline
        N & 6 & 45 \\ 
        [...] \\
        \hline
        \caption{B}
    \end{longtable}
    \arrayrulecolor{black}
\end{minipage} 

I would very much appreciate a hint or even exact solution, how my captions get centered below the tables. Furthermore, I assume I could use \vspace*{-Xmm} to move the caption vertically, if necessary.

Thanks a lot in advance and best regards DomHaw

DomHaw
  • 1
  • 2
    Putting longtable in a minipage doesn't make any sense, that's just tabular with extra steps. longtable is all about being page-breakable, whereas a minipage can't be broken. – Skillmon Jan 18 '21 at 10:59
  • 1
    Correct would be \begin{minipage}{.45\linewidth}\centering\begin{tabular}...\end{tabular}\captionof{table}{...}\end{minipage}\hfill\begin{minipage}{.45\linewidth}\centering\begin{tabular}...\end{tabular}\captionof{table}{...}\end{minipage}. \captionof is provided by the KOMA-script class (scrartcl, scrreprt, scrbook), the capt-of package, or the caption package (if you use either of these you don't need the rest, the most lightweight variant is capt-of). – Skillmon Jan 18 '21 at 11:01
  • do not just post sippets that can not be tested, post small complete documents, but as Skillmon says never put a longtable in a minipage. – David Carlisle Jan 18 '21 at 11:11
  • longtable captions are centred by default so what exactly is your question, what do you want to change from the default behaviour? – David Carlisle Jan 18 '21 at 11:16
  • @David. Sorry, I should have kept [...] out. Then the code should run totally fine. Unfortunately the caption is not centered as you can see on my screenshot. 'Table 12' and 'Table 13' are way too far right. Yes, Skillmons answer sounds plausible and I am just checking it right now. – DomHaw Jan 18 '21 at 12:16
  • I don't understand that comment. the code is using longtable in a minipage so is definitely not "fine" but we can not run it as there is no \documentclass or \begin{document} perhaps I can guess which package you used to define \arrayrulecolor (as I wrote it) but you should not make people have to guess. – David Carlisle Jan 18 '21 at 12:19
  • @David: You are totally right. Also \usepackages and so on are missing. Sorry for the inconveniences! I did not want my post to become too long, but it makes sense to have everything on board. – DomHaw Jan 18 '21 at 12:42
  • @Skillmon: Thanks, your idea helped. I got rid of the longtable and used tabular instead. \begin{table} \begin{minipage} \begin{tabluar} \end_all – DomHaw Jan 18 '21 at 12:43
  • \begin{table}\begin{minipage}... doesn't make much sense as well (except if you put both minipages in the same table environment). If you want the tables to be able to float that would indeed be the correct approach. – Skillmon Jan 18 '21 at 14:21

0 Answers0