0

I am new to TeX and I have been encountering a few issues that I couldn't resolve on my own as I've been doing so far. I am wondering how to color the row while using the command \multirow without seeing only half of the writing of the merged cell. Also, how can I align the decimals (using the '.' and not ',') while remaining in the center of the cell? Lastly, how can I set the width of a column (and also the height of a row)? Sometimes I have wide columns when I don't need them or vice-versa.

Thank you in advance!!

\usepackage{multirow}
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{xcolor}

\begin{figure}[H]
\centering
\includegraphics[width=0.7\textwidth]{figures/filtrsecr}
\caption{Models of excretion rate for different molecules.}
\label{filtrsecr}
\end{figure}

\begin{table}[!h]
    \centering
     \small
        \setlength\tabcolsep{2pt}
    \begin{tabular}{|c||c|c|c|c|c|c|}
    \hline \hline
& Unit & Filtered load & Amount reabsorbed & Amount secreted & Amount excreted & Filtered load \\
& & &  &  &  & reabsorbed (\%) \\
 \hline
 \rowcolor{LightGreen}
$ Na^+ $ & $mEq/day$ & 25200 & 25410 & 0 & 150 & 99.4 \\
\rowcolor{Ivory}
$ Cl^- $ & $mEq/day$ & 18000 & 17850 & 0 & 150 & 99.2 \\
\rowcolor{LightGreen}
${HCO_3}^- $& $mEq/day$ & 4320 & 4318 & 0 & 2 & 99.9 \\
\rowcolor{Ivory}
$ K^+ $& $mEq/day$ & 720 & 620 & 50 & 100 & 86.1 \\

\multirow{2}{*}{\cellcolor{LightGreen} $Ca^{2+}$}
& \cellcolor{LightGreen} $mEq/day$ & \cellcolor{LightGreen} 540 & \cellcolor{LightGreen}530 & \cellcolor{LightGreen} 0 & \cellcolor{LightGreen} 10 & \cellcolor{LightGreen} 98.1 \\ 
\cellcolor{Ivory} & \cellcolor{Ivory} $mmol/day$ & \cellcolor{Ivory} 270 & \cellcolor{Ivory} 265 & \cellcolor{Ivory} 0 & \cellcolor{Ivory} 5 & \cellcolor{Ivory} 98.1 \\

\multirow{2}{*}{\cellcolor{LightGreen} ${HPO_4}^{2-}$}
& \cellcolor{LightGreen} $mEq/day$ & \cellcolor{LightGreen} 260 & \cellcolor{LightGreen} 234 & \cellcolor{LightGreen} 0 & \cellcolor{LightGreen} 26 & \cellcolor{LightGreen} 90 \\
\cellcolor{Ivory} & \cellcolor{Ivory} $mmol/day$ & \cellcolor{Ivory} 144 & \cellcolor{Ivory} 130 & \cellcolor{Ivory} 0 & \cellcolor{Ivory} 14 & \cellcolor{Ivory} 90 \\ 

\rowcolor{LightGreen}
$ Urea $ & $mmol/day$ & 870 & 460 & 0 & 410 & 52.9 \\
\rowcolor{Ivory}
$ Glucose $ & $mmol/day$ & 800 & 799.5 & 0 & 0.5 & 99.9 \\
\rowcolor{LightGreen}
$ Uric\ acid $ & $mmol/day$ & 50 & 49 & 4 & 5 & 98 \\
\rowcolor{Ivory}
$ Creatinine $ & $mmol/day$ & 12 & 0 & 1 & 12 & 0 \\
\rowcolor{LightGreen}
$ Total\ solute $ & $mmol/day$ & 50386 & 49541.5 & 55 & 848.5 & 98 \\
\rowcolor{Ivory}
$ Water $ & $ml/day$ & 180000 & 179000 & 0 & 1000 & 99.4 \\
    \hline \hline
    \end{tabular}
    \caption{Filtration, reabsorption, secretion and excretion rates referring to each substance \cite{RefWorks:130}.}
    \label{filtreabsecret}
\end{table}

Table

  • For the usage of rowcolor with multirow you can have a look at the following link: tex.stackexchange.com/a/269549/134144 Alignment of numbers in cells can be achieved by using the S column of the siunitx package. In your current setup coumn widths are calculated automatically. For fixed width colmns you could use p cells. For individual handling of linebreaks in single cells, the makecell package might be useful as well. – leandriis Sep 26 '17 at 10:26
  • Welcome to TeX.SX! Please always ask only one question per question. And please always add a minimal but working example (MWE) instead of code snippets. – Schweinebacke Sep 26 '17 at 11:01
1

Here is a solution, which requires a few more packages, amongst which chemformula which has a command to type chemistry formulae and reactions in a simple way and makecell, which allows for line breaks in standard cells. I propose a design with hhline, which looks nicer than the default \hlines with coloured rows.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage[demo]{graphicx}
\usepackage{tabularx, longtable, multirow, booktabs, hhline, makecell, cellspace}
\setlength{\cellspacetoplimit}{2pt}
\setlength{\cellspacebottomlimit}{2pt}
\usepackage{array}
\usepackage[table, svgnames]{xcolor}
\usepackage{chemformula}
\usepackage{siunitx}
\DeclareSIUnit{\mEq}{mEq}

\begin{document}

\begin{figure}[!htb]
  \centering
  \includegraphics[width=0.7\textwidth]{figures/filtrsecr}
  \sisetup{table-number-alignment=center}
  \caption{Models of excretion rate for different molecules.}
  \label{filtrsecr}
\end{figure}

\begin{table}[!h]
  \centering\renewcommand{\theadfont}{\small}
  \small\sisetup{per-mode=symbol}
  \setlength{\doublerulesep}{5pt}
  \rowcolors{3}{LightGreen}{Ivory}
  \begin{tabular}{|Cc||Cr|S[table-format=6.0]|S[table-format=6.1]| S[table-format=2.0]|S[table-format=4.1]|S[table-format=2.1]|}
    \hhline{~------}
    \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Unit} & {\thead{Filtered \\ load}} & {\thead{Amount\\ reabsorbed}} & {\thead{Amount\\ secreted}} & {\thead{Amount\\ excreted}} & {\thead{Filtered load\\ reabsorbed\\ (\%)}} \\
    \hhline{-::======:}
    \ch{Na+} & \si{\mEq/\day} & 25200 & 25410 & 0 & 150 & 99.4 \\
    \ch{Cl-} & \si{\mEq/\day} & 18000 & 17850 & 0 & 150 & 99.2 \\
    \ch{HCO_3-} & \si{\mEq/\day} & 4320 & 4318 & 0 & 2 & 99.9 \\
    \ch{K+ } & \si{\mEq/\day} & 720 & 620 & 50 & 100 & 86.1 \\
                                                            & \si{\mEq/\day} & 540 & 530 & 0 & 10 & 98.1 \\
    \multirow{-2}{*}{\cellcolor{Ivory}\ch{Ca^{2+}}} & \si{\mmol/\day} & 270 & 265 & 0 & 5 & 98.1 \\
    \cellcolor{LightGreen} & \si{\mEq/\day} & 260 & 234 & 0 & 26 & 90 \\
    \multirow{-2}{*}{\cellcolor{LightGreen}\ch{HPO_4^{2-}}} & \si{\mmol/\day} & 144 & 130 & 0 & 14 & 90 \\
    Urea & \si{\mmol/\day} & 870 & 460 & 0 & 410 & 52.9 \\
    Glucose & \si{\mmol/\day} & 800 & 799.5 & 0 & 0.5 & 99.9 \\
    Uric\ acid & \si{\mmol/\day} & 50 & 49 & 4 & 5 & 98 \\
    Creatinine & \si{\mmol/\day} & 12 & 0 & 1 & 12 & 0 \\
    Total\ solute & \si{\mmol/\day} & 50386 & 49541.5 & 55 & 848.5 & 98 \\
    Water & \si{\ml/\day} & 180000 & 179000 & 0 & 1000 & 99.4 \\
    \hhline{-||------}
  \end{tabular}
  \caption{Filtration, reabsorption, secretion and excretion rates referring to each substance \cite{RefWorks:130}.}
  \label{filtreabsecret}
\end{table}

\end{document} 

enter image description here

  • you have unicode problem with your editor again : -). please correct HCO₃- to HCO_3- and HPO₄^{2-} to HPO_4^{2-} . – Zarko Sep 26 '17 at 12:18
  • @Zarko: Thanks for warning me. I'll fix it within a few seconds! – Bernard Sep 26 '17 at 12:19
  • What is the difference between Cc and Cr, both used in the definition of the tabular environment? – silvia26 Sep 28 '17 at 8:31
  • Oh! Sorry, I forgot to explain this technical point. C is a prefix before the standard specifiers c and r, to add the minimal vertical padding defined by cellspace at the top and bottom of cells (\cellspacetoplimit and \cellspacebottomlimit). Normally, the letter Sshould be used (Sc and Sr), but with siunitx, which defines S columns, we have to use C. So the first column is centred (with padding) whereas the second is right-aligned (I thought it looked nicer this way). – Bernard Sep 28 '17 at 8:41
  • Also, how do you decide the number under the name of table-format, in square brackets after S? – silvia26 Sep 28 '17 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.