'Centered Cells in Latex
Hello I'm trying to use cells in latex.
How do you put the "Func2" and the "-" centered in the cell?
The code I'm using is:
\begin{tabularx}{0.8\textwidth} {
| >{\raggedright\arraybackslash}X
| >{\centering\arraybackslash}X
| >{\raggedleft\arraybackslash}X | }
\hline
\multicolumn{3}{|c|}{2D - $L = 64$} \\
\hline
Speedup(x) & Func1 & Func2 \\
\hline
Func2 & 35.4 & - \\
\hline
Func3 & 322.8 & 9.1 \\
\hline
\end{tabularx}
Solution 1:[1]
You could use the tabularray package. This makes it easy to change the alignment for individual cells:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
width={0.8\textwidth},
colspec={|X|X[halign=c]|X[halign=r]|}
}
\hline
\SetCell[c=3]{halign=c} 2D - $L = 64$ \\
\hline
Speedup(x) & Func1 & \SetCell{halign=c} Func2 \\
\hline
Func2 & 35.4 & \SetCell{halign=c} - \\
\hline
Func3 & 322.8 & 9.1 \\
\hline
\end{tblr}
\end{document}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | samcarter_is_at_topanswers.xyz |

