我有这张表的代码:
\begin{table}[!h]
\normalsize
\caption{Anything.}
\label{tab:anm_estampas}
\begin{center}
%\setlength{\tabcolsep}{8pt}
\begin{tabular}{l | c | l | c }
\hline Text1 & Text2 & Text3 & Text4 \\\hline
Resistor & \figresistor & \estamparesistor & \eqresistor \\
Fonte de Corrente & \figfontecorrentecc & \estampafontecorrentecc & \eqfontecorrentecc
\end{tabular}
\end{center}
\fonte{Figuras do Autor}
\end{table}
单元格内的命令只是用于放置图像和方程式的宏:
\newcommand{\figresistor}{%
\includegraphics[width=2cm]{estampa_simbolo_resistor.eps}
}
\newcommand{\figfontecorrentecc}{%
\includegraphics[height=2cm]{estampa_simbolo_fontecorrentecc.eps}
}
\newcommand{\estamparesistor}{%
\includegraphics[width=2.5cm]{estampa_matriz_resistor.eps}
}
\newcommand{\estampafontecorrentecc}{%
\includegraphics[width=1.2cm]{estampa_matriz_fontecorrentecc.eps}
}
\newcommand{\eqresistor}{%
\ensuremath{%
\begin{aligned}
I_j = G(V_j-V_{j'}) \\
I_{j'} = -G(V_j-V_{j'})
\end{aligned}
}%
}
\newcommand{\eqfontecorrentecc}{%
\ensuremath{%
\begin{aligned}
I_j = J \\
I_{j'} = -J
\end{aligned}
}%
}
我尝试了很多方法,例如在每个单元格内居中,但都没有任何效果。
如何才能水平和垂直地集中所有单元格内容?提前致谢!
答案1
答案2
- 你应该提供 MWE
- 没有它答案就不完整
- 我不会把数学作为图像
- 通过使用
tabularray
包,解决问题的一个可能方法是:
\documentclass[margin=3mm, varwidth]{standalone}
\usepackage[export]{adjustbox}
\usepackage{tabularray}
\UseTblrLibrary{amsmath}
\newcommand\figresistor{\includegraphics[width=5em,valign=m]{example-image-duck}}
\newcommand\estamparesistor{\includegraphics[width=5em,valign=m]{example-image-duck}}
\begin{document}
\begin{table}[!h]
\caption{Anything.}
\label{tab:anm_estampas}
\centering
\begin{tblr}{hline{1,2}=solid, vlines,
colspec={Q[l,m] Q[c] Q[c] Q[c,mode=math]},
row{1}={font=\bfseries, mode=text, c},
rowsep=5pt
}
Text 1 & Text 2 & Text 3 & Text 4 \\
Resistor & \figresistor
& \estamparesistor
& \begin{aligned}
I_j & G(V_j-V_j') \\
I_j'& - G(V_j-V_j')
\end{aligned} \\
Fonte de Corrente
& \figresistor
& \estamparesistor
& \begin{aligned}
I_j & J \\
I_j'& - J
\end{aligned} \\
\end{tblr}
\caption{Figuras do Autor}
\end{table}
\end{document}