How to connect cell vertical lines of a table in latex - latex

In the Following table, I am experiencing a disconnection in the vertical cell lines as shown in the image.
\begin{table*}[!htb]
\caption{}
\begin{center}
\label{tab:Apps}
%\small\setlength\tabcolsep{6pt}
\begin{tabular}
{|p{0.13\textwidth}|p{0.43\textwidth}|p{0.15\textwidth}|p{0.18\textwidth}|}
% \toprule
%\hline
\hline
\centering{\textbf{Text}} & \centering {\textbf{Text}} & \centering{\textbf{Text}} &\textbf{Text}\\
\hline
\begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \vspace{-2pt}\begin{itemize}[leftmargin=*, noitemsep, topsep=0pt] \item Text. \vspace*{-1.7\baselineskip} \end{itemize} & \begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \\
\hline
\begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \vspace{-2pt}\begin{itemize}[leftmargin=*, noitemsep, topsep=0pt] \item Text. \vspace*{-1.7\baselineskip} \end{itemize} & \begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \begin{flushright}\centering Text \vspace*{-3pt} \end{flushright} & \\
\hline
\end{tabular}
\end{center}
\end{table*}

Related

Vertical and horizontal cell centering in LaTex table

I am making a LaTex table and have trouble centering text (and images) inside cells themselves. The table as a whole is centered on the page, but what I want is that text and images in every cell are centered both vertically and horizontally.
This is my code
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{tabularray}
\usepackage{float}
\usepackage{graphicx}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|c|}
\hline
\rowcolor[HTML]{C0C0C0}
\textbf{Particle} & \textbf{Orientation} & \textbf{Symbol} & \textbf{Letter} \\[4ex] \hline
& in & {\includegraphics[scale=0.8]{im/inel.jpg}} & $u$ \\[2ex] \cline{2-4}
\multirow{-2}{*}{fermion} & out & {\includegraphics[scale=0.8]{im/outel.jpg}} & $\overline{u}$ \\[2ex] \hline
& in & {\includegraphics[scale=0.8]{im/inpoz.jpg}} & $\overline{v}$ \\[2ex] \cline{2-4}
\multirow{-2}{*}{antifermion} & out & {\includegraphics[scale=0.8]{im/outpoz.jpg}} & $v$ \\[2ex] \hline
& in & {\includegraphics[scale=0.8]{im/inph.jpg}} & $\epsilon_\mu$ \\[2ex] \cline{2-4}
\multirow{-2}{*}{foton} & out & {\includegraphics[scale=0.8]{im/outph.jpg}} & $\epsilon_{\mu}^*$ \\[2ex] \hline
\end{tabular}
\end{table}
\end{document}
This is what my code gives me (also notice how some lines are obscured by the images - that is not how I wanted it):
And, this is what I want:
Any help is welcome! Thank you
You are already loading the tabularray package, just use it instead of a tabular:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{tabularray}
\usepackage{float}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\begin{document}
\begin{table}[H]
\centering
\begin{tblr}{
cells={valign=m,halign=c},
row{1}={bg=lightgray,font=\bfseries,rowsep=8pt},
colspec={QQQQ},
hlines,
vlines
}
Particle & Orientation & Symbol & Letter\\
\SetCell[r=2]{} fermion& in & \includegraphics[scale=0.5,valign=c]{example-image-duck} & $u$ \\
& out & \includegraphics[scale=0.5,valign=c]{example-image-duck}& $\overline{u}$ \\
\SetCell[r=2]{} antifermion & in & \includegraphics[scale=0.5,valign=c]{example-image-duck} & $\overline{v}$ \\
& out & \includegraphics[scale=0.5,valign=c]{example-image-duck} & $v$ \\
\SetCell[r=2]{} photon & in & \includegraphics[scale=0.5,valign=c]{example-image-duck} & $\epsilon_\mu$ \\
& out & \includegraphics[scale=0.5,valign=c]{example-image-duck} & $\epsilon_{\mu}^*$ \\
\end{tblr}
\end{table}
\end{document}

Table reference not working properly when using \setcounter{table}{0} in appendix in latex

I am trying to fix an issue with my latex document, and need help.
I am using \documentclass[12pt]{article} environment in Latex. The issue is the following:
I have added an appendix using
\appendix
\section{Appendix}\label{appendix_a}
and used
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
to generate table names as Table A1 and so on.
However, when I use \setcounter to restart the table numbering, my labels stop working. But if I remove the \setcounter command, my labels work perfectly, but then the table number continue from where I left before appendix, that is Table A6 and not Table A1.
Here is my minimum working example:
\documentclass[12pt]{article}
\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref,booktabs,dcolumn,threeparttable, adjustbox,apacite,dirtytalk,multirow,tabularx,booktabs}
\usepackage{ulem}
\usepackage{float}
\restylefloat{table}
\begin{document}
\section{Section A}
Table \ref{tab_main} is the first table.
\begin{table}
\centering
\input{Main_Table}
\caption{Main Table}
\label{tab_main}
\end{table}
See table \ref{tab_appendix} in the appendix.
\appendix
\section{Appendix}\label{appendix_a}
%\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
\begin{table}
\input{Appendix_Table}
\caption{Appendix Table}
\label{tab_appendix}
\end{table}
\end{document}
And here are tables that I have used:
Main_Table.tex
\begin{centre}
\begin{table}[H]
\\[-1.8ex]\hline
\hline \\[-1.8ex]
\begin{tabularx}{1\textwidth}{>{\raggedright\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X}
\small
& & \multicolumn{3}{c}{Heading} \\
\midrule
\multicolumn{2}{l}{Koo} & 1 & 2 & 3 \\
\multicolumn{2}{l}{Koo} & 1 & 2 & 3 \\
\midrule
\multicolumn{2}{l}{Koo} & A & B & C \\
\multicolumn{2}{l}{Koo} & A & B & C \\
\multicolumn{2}{l}{Koo} & A & B & C \\
\multicolumn{2}{l}{Koo} & A & B & C \\
\tiny
\end{tabularx}
\hline
\hline \\[-1.8ex]
\smallskip
\multicolumn{5}{l}{\parbox[t]{\textwidth}{\footnotesize{\emph{Notes}: Main}}}
\end{table}
\end{centre}
Appendix_Table.tex
\begin{centre}
\begin{table}[H]
\\[-1.8ex]\hline
\hline \\[-1.8ex]
\begin{tabularx}{1\textwidth}{>{\raggedright\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X >{\centering\arraybackslash}X}
\small
& & \multicolumn{3}{c}{Heading} \\
\midrule
\multicolumn{2}{l}{Foo} & 1 & 2 & 3 \\
\multicolumn{2}{l}{Foo} & 1 & 2 & 3 \\
\midrule
\multicolumn{2}{l}{Foo} & A & B & C \\
\multicolumn{2}{l}{Foo} & A & B & C \\
\multicolumn{2}{l}{Foo} & A & B & C \\
\multicolumn{2}{l}{Foo} & A & B & C \\
\tiny
\end{tabularx}
\hline
\hline \\[-1.8ex]
\smallskip
\multicolumn{5}{l}{\parbox[t]{\textwidth}{\footnotesize{\emph{Notes}: Appendix}}}
\end{table}
\end{centre}
Any help on this front would be appreciated.
Thank You
\documentclass[12pt]{article}
\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,color,setspace,sectsty,comment,footmisc,caption,pdflscape,subfigure,array,hyperref,booktabs,dcolumn,threeparttable, adjustbox,apacite,dirtytalk,multirow,tabularx,booktabs}
\usepackage{ulem}
\usepackage{float}
\restylefloat{table}
\usepackage{appendix}
\begin{document}
\section{Section A}
Table \ref{tab_main} is the first table.
\begin{table}[htbp]
\centering
main table
\caption{Main Table}
\label{tab_main}
\end{table}
See table \ref{tab_appendix} in the appendix.
\appendix
\section{Appendix}\label{appendix_a}
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
\renewcommand*{\theHtable}{\thetable}
\begin{table}[htbp]
\centering
appendix table
\caption{Appendix Table}
\label{tab_appendix}
\end{table}
\end{document}

LaTeX - full width row on a tabular - cell occupying multiple cells

I am trying to recreate this table on Latex:
https://i.imgur.com/0Yu3rgp.png
but I can't figure out how to have a cell occupying three cells instead of just one (for the Tritanomaly percentage entry for example).
This is the best that I've been able to do so far:
\usepackage{slashbox}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[h]
\centering
{\rowcolors{2}{gray!15}{gray!0}
\begin{tabular}{|l||c|c|c|}
\hline
\backslashbox{CVD}{Sex}
&Male&Female&\textbf{Any}\\\hline\hline
Deuteranomaly & 5\% & 0.35\% & 2.68\% \\\hline
Deuteranopia & 1\% & 0.1\% & 0.56\% \\\hline
Protanomaly & 1.08\% & 0.03\% & 0.55\% \\\hline
Protanopia & 1.01\% & 0.01\% & 0.51\% \\\hline
Tritanomaly* && 0.02\% & \\ \hline
Tritanopia* && 0.01\% &\\\hline
Monochromacy* && 0.0001\% &\\\hline
\textbf{Total} & \textbf{8.12}\% & \textbf{0.52}\% & \textbf{4.32}\% \\\hline
\end{tabular}
\end{table}
\end{document}
Thank you in advance
\multicolumn is your new best friend:
\documentclass{article}
\usepackage{slashbox}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[h]
\centering
\rowcolors{2}{gray!15}{gray!0}
\begin{tabular}{|l||c|c|c|}
\hline
\backslashbox{CVD}{Sex}
&Male&Female&\textbf{Any}\\\hline\hline
Deuteranomaly & 5\% & 0.35\% & 2.68\% \\\hline
Deuteranopia & 1\% & 0.1\% & 0.56\% \\\hline
Protanomaly & 1.08\% & 0.03\% & 0.55\% \\\hline
Protanopia & 1.01\% & 0.01\% & 0.51\% \\\hline
Tritanomaly* & \multicolumn{3}{c|}{0.02\%} \\ \hline
Tritanopia* &\multicolumn{3}{c|}{0.02\%}\\\hline
Monochromacy* &\multicolumn{3}{c|}{0.02\%}\\\hline
\textbf{Total} & \textbf{8.12}\% & \textbf{0.52}\% & \textbf{4.32}\% \\\hline
\end{tabular}
\end{table}
\end{document}

How to vertically center my latex table cell

My Latex tabular looks like this
\begin{table}
\centering
\begin{tabular}{clll}
\toprule
\multirow{2}*{Name} & \multirow{2}*{Description} & \multicolumn{2}{c}
{Time} \\
\cline{3-4}
& & Item1 & Item2 \\
\midrule
App1 & Good & 1000ms & 1000ms \\
\bottomrule
\end{tabular}
\end{table}
'
I wonder how can I make Item1 and Item2 in the above table vertically-centered. Thank you!
You can use the command \cmidrule{3-4}: it is equivalent to \cline{3-4}, but it improves the looking of the table.
\documentclass{article}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}
\begin{table}
\begin{center}
\begin{tabular}{clll}
\toprule
\multirow{2}*{Name} & \multirow{2}*{Description} & \multicolumn{2}{c} {Time} \\
\cmidrule{3-4}
& & Item1 & Item2 \\
\midrule
App1 & Good & 1000ms & 1000ms \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\end{document}

\footnote gives error in minipage environment with cta-author class

I need to use \footnote in a minipage environment, but it always gives an error
Command \itshape invalid in math mode. a\footnote{
mwe is
\documentclass{cta-author}
\begin{document}
\begin{table}
\begin{minipage}{\columnwidth}
\begin{tabular}{|c|c|}
\hline
Column 1 & Column2 \\
a\footnote{footnote example} & b\\
\hline
\end{tabular}
\end{minipage}
\end{table}
\end{document}
Latex class file is here
You can redefine the way cta-author makes the footnote mark. Instead of $^{...}$, use \textsuperscript{...}:
\documentclass{cta-author}
\makeatletter
\def\#makefnmark{\textsuperscript{\#thefnmark}}
\makeatother
\begin{document}
\begin{table}
\begin{minipage}{\columnwidth}
\begin{tabular}{|c|c|}
\hline
Column 1 & Column2 \\
a\footnote{footnote example} & b \\
\hline
\end{tabular}
\end{minipage}
\end{table}
% A possible work-around
\begin{table}
\begin{tabular}{|c|c|}
\hline
Column 1 & Column2 \\
a$^*$ & b \\
\hline
\end{tabular}
\medskip
\footnoterule
{\itshape\footnotesize $^*$footnote example}
\end{table}
\end{document}
And here is a visual of the work-around:

Resources