GeneralHow to make parbox center in table?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
marbocam
Posts: 38
Joined: Thu Dec 19, 2024 11:14 am

How to make parbox center in table?

Post by marbocam »

I have a table were I'm using parbox to be able to have equations, the problem is that I want to center the first row:

Code: Select all

\begin{table}[ht]
\caption{CURRENT AMPLITUDE RESPONSE AT LOW FREQUENCIES IN THE MMW BAND (SMALL SIGNAL REGIME)}
\centering
\begin{tabular}{lp{8cm}}
\hline\hline
& $i(2\omega_{RF}\pm\omega_{IF})$\\
\hline
OB2B& \begin{equation}
\Re P_0 m_{AM}m_{RF}^2sin^2 \varphi_{DC}  \label{gain_OB2B}
\end{equation}\\
SSMF& \begin{equation}
\Re P_0 m_{AM}m_{RF}^2sin^2 \varphi_{DC}(1\pm j \alpha \kappa P_0 \beta L \omega_{RF}) \label{gain_SSMF}
\end{equation}\\
\hline\hline
\end{tabular} \label{gainTable1}
\end{table}
Any ideas on how to achieve this?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

How to make parbox center in table?

Post by Stefan Kottwitz »

Welcome to the forum!

You can insert \centering in that cell, but then also use \arraybackslash and the array package.

By the way, while commonly variables are written using an italic/cursive font, operators, units, and other expressions are usually written upright. There are commands for this, such as \sin and \cos. You can define new operators or use \mathrm for Roman (upright) font. Like this:

Code: Select all

\documentclass{article}
\usepackage[font=sc]{caption}
\usepackage{array}
\newcommand*{\AM}{\mathrm{AM}}
\newcommand*{\RF}{\mathrm{RF}}
\newcommand*{\IF}{\mathrm{IF}}
\newcommand*{\DC}{\mathrm{DC}}
\begin{document}
\begin{table}[ht]
\caption{Current amplitude response at low frequencies in the mmw band (small signal regime)}
\centering
\begin{tabular}{lp{8cm}}
\hline\hline
& \centering\arraybackslash $i(2\omega_{\RF}\pm\omega_{\IF})$\\
\hline
OB2B& \begin{equation}
\Re P_0 m_{\AM}m_{\RF}^2\sin^2 \varphi_{\DC}  \label{gain_OB2B}
\end{equation}\\
SSMF& \begin{equation}
\Re P_0 m_{\AM}m_{\RF}^2\sin^2 \varphi_{\DC}(1\pm j \alpha \kappa P_0 \beta L \omega_{\RF}) \label{gain_SSMF}
\end{equation}\\
\hline\hline
\end{tabular}\label{gainTable1}
\end{table}
\end{document}
You can also check good modern books in your field of science how they display operators, units, and other text in mathematical equations.

You could also consider using small caps instead of writing caption texts all in capital letters, which some may not consider good style. Using \textsc, \scshape, or the caption package with sc. Click on "Run LaTeX here" to see how it looks.

Stefan
LaTeX.org admin
marbocam
Posts: 38
Joined: Thu Dec 19, 2024 11:14 am

How to make parbox center in table?

Post by marbocam »

Thank you ^^ You guys rock! As you can see, I'm pretty new to Latex :P
marbocam
Posts: 38
Joined: Thu Dec 19, 2024 11:14 am

How to make parbox center in table?

Post by marbocam »

Hi again, quick question. Is it possible to center vertically OB2B and SSMF with the equation? It would look much nicer :)
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

How to make parbox center in table?

Post by Stefan Kottwitz »

Equations within a table are very unusual, so it's not directly well supported with alignment, but as a quick hack you could do a similar "equation" in the first column so it gets the same height and alignment:

Code: Select all

\documentclass{article}
\usepackage[font=sc]{caption}
\usepackage{array}
\usepackage{amsmath}
\newcommand*{\AM}{\mathrm{AM}}
\newcommand*{\RF}{\mathrm{RF}}
\newcommand*{\IF}{\mathrm{IF}}
\newcommand*{\DC}{\mathrm{DC}}
\begin{document}
\begin{table}[ht]
\caption{Current amplitude response at low frequencies in the mmw band (small signal regime)}
\centering
\begin{tabular}{p{2.5cm}p{9cm}}
\hline\hline
& \centering\arraybackslash $i(2\omega_{\RF}\pm\omega_{\IF})$\\
\hline
\[\text{OB2B}\] & \begin{equation}
\Re P_0 m_{\AM}m_{\RF}^2\sin^2 \varphi_{\DC}  \label{gain_OB2B}
\end{equation}\\
\[\text{SSMF}\] & \begin{equation}
\Re P_0 m_{\AM}m_{\RF}^2\sin^2 \varphi_{\DC}(1\pm j \alpha \kappa P_0 \beta L \omega_{\RF}) \label{gain_SSMF}
\end{equation}\\
\hline\hline
\end{tabular}\label{gainTable1}
\end{table}
\end{document}
table-equations.png
table-equations.png (26 KiB) Viewed 3247 times
Stefan
LaTeX.org admin
Post Reply