3

I have a table and I want to multiply the table with some scalar value say 6 is it possible to do in latex?

\documentclass
\usepackage{multirow}
\begin{table}[]
\begin{tabular}{ccccccccc}
\hline
\multirow{3}{*}{$\rho_{r}=\frac{\rho_{1}}{\rho}$} & \multicolumn{8}{c}{Symmetric non-dimensional frequencies}                                                                             \\ \cline{2-9} 
                                                  & \multicolumn{2}{c}{$\beta_{1}$} & \multicolumn{2}{c}{$\beta_{2}$} & \multicolumn{2}{c}{$\beta_{3}$} & \multicolumn{2}{c}{$\beta_{4}$} \\ \cline{2-9} 
                                                  & DROM           & FEM            & DROM           & FEM            & DROM           & FEM            & DROM           & FEM            \\ \hline
1                                                 & 1.213          & 1.212          & 2.208          & 2.201          & 3.141          & 3.123          & 3.602          & 3.569          \\ \hline
10                                                & 1.213          & 1.212          & 2.208          & 2.201          & 3.141          & 3.123          & 3.602          & 3.567          \\ \hline
1e2                                               & 1.213          & 1.213          & 2.208          & 2.208          & 3.141          & 3.123          & 3.602          & 3.249          \\ \hline
1e3                                               & 1.213          & 1.212          & 2.208          & 1.853          & 3.141          & 2.203          & 3.602          & 3.123          \\ \hline
\multirow{3}{*}{$\rho_{r}=\frac{\rho_{1}}{\rho}$} & \multicolumn{8}{c}{Anti-symmetric non-dimensional frequencies}                                                                        \\ \cline{2-9} 
                                                  & \multicolumn{2}{c}{$\beta_{1}$} & \multicolumn{2}{c}{$\beta_{1}$} & \multicolumn{2}{c}{$\beta_{1}$} & \multicolumn{2}{c}{$\beta_{1}$} \\ \cline{2-9} 
                                                  & DROM           & FEM            & DROM           & FEM            & DROM           & FEM            & DROM           & FEM            \\ \hline
1                                                 & 0.762          & 0.761          & 1.492          & 1.491          & 2.306          & 2.298          & 3.141          & 3.123          \\ \hline
10                                                & 0.634          & 0.633          & 1.304          & 1.302          & 2.232          & 2.225          & 3.141          & 3.123          \\ \hline
1e2                                               & 0.398          & 0.397          & 1.225          & 1.223          & 2.212          & 2.204          & 3.141          & 3.123          \\ \hline
1e3                                               & 0.226          & 0.226          & 1.215          & 1.215          & 2.209          & 2.203          & 3.141          & 2.623          \\ \hline
\end{tabular}
\end{table}

\end{document}

  • Could you please consider providing a compilable code. The document class, \begin{document} and \end{document} are missing. – Schrödinger's cat Sep 22 at 5:18
5

Yes, of course. With collcell. All one needs to do is to install some parser that parses and evaluates the entries, with my choice being \pgfmathparse.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow}
\usepackage{collcell}
\usepackage{pgf}
\newcolumntype{E}{>{\collectcell\usermacro}c<{\endcollectcell}}
\newcommand\usermacro[1]{\pgfmathparse{6*#1}\pgfmathprintnumber\pgfmathresult}

\begin{document}
\begin{table}[htb]
\centering\pgfkeys{/pgf/number format/fixed,
          /pgf/number format/fixed zerofill,
          /pgf/number format/precision=3}
\begin{tabular}{cEEEEEEEE}
\hline
\multirow{3}{*}{$\rho_{r}=\frac{\rho_{1}}{\rho}$} & \multicolumn{8}{c}{Symmetric non-dimensional frequencies}                                                                             \\ \cline{2-9} 
                                                  & \multicolumn{2}{c}{$\beta_{1}$} & \multicolumn{2}{c}{$\beta_{2}$} & \multicolumn{2}{c}{$\beta_{3}$} & \multicolumn{2}{c}{$\beta_{4}$} \\ \cline{2-9} 
                                                  & \multicolumn{1}{c}{DROM}  & \multicolumn{1}{c}{FEM}            & \multicolumn{1}{c}{DROM}           & \multicolumn{1}{c}{FEM}            & \multicolumn{1}{c}{DROM}           & \multicolumn{1}{c}{FEM}            & \multicolumn{1}{c}{DROM}           & \multicolumn{1}{c}{FEM}            \\ \hline
1                                                 & 1.213          & 1.212          & 2.208          & 2.201          & 3.141          & 3.123          & 3.602          & 3.569          \\ \hline
10                                                & 1.213          & 1.212          & 2.208          & 2.201          & 3.141          & 3.123          & 3.602          & 3.567          \\ \hline
1e2                                               & 1.213          & 1.213          & 2.208          & 2.208          & 3.141          & 3.123          & 3.602          & 3.249          \\ \hline
1e3                                               & 1.213          & 1.212          & 2.208          & 1.853          & 3.141          & 2.203          & 3.602          & 3.123          \\ \hline
\multirow{3}{*}{$\rho_{r}=\frac{\rho_{1}}{\rho}$} & \multicolumn{8}{c}{Anti-symmetric non-dimensional frequencies}                                                                        \\ \cline{2-9} 
                                                  & \multicolumn{2}{c}{$\beta_{1}$} & \multicolumn{2}{c}{$\beta_{1}$} & \multicolumn{2}{c}{$\beta_{1}$} & \multicolumn{2}{c}{$\beta_{1}$} \\ \cline{2-9} 
                                                  & \multicolumn{1}{c}{DROM}  & \multicolumn{1}{c}{FEM}            & \multicolumn{1}{c}{DROM}           & \multicolumn{1}{c}{FEM}            & \multicolumn{1}{c}{DROM}           & \multicolumn{1}{c}{FEM}            & \multicolumn{1}{c}{DROM}           & \multicolumn{1}{c}{FEM}            \\ \hline
1                                                 & 0.762          & 0.761          & 1.492          & 1.491          & 2.306          & 2.298          & 3.141          & 3.123          \\ \hline
10                                                & 0.634          & 0.633          & 1.304          & 1.302          & 2.232          & 2.225          & 3.141          & 3.123          \\ \hline
1e2                                               & 0.398          & 0.397          & 1.225          & 1.223          & 2.212          & 2.204          & 3.141          & 3.123          \\ \hline
1e3                                               & 0.226          & 0.226          & 1.215          & 1.215          & 2.209          & 2.203          & 3.141          & 2.623          \\ \hline
\end{tabular}
\end{table}
\end{document}

enter image description here

  • Thanks for your time and effort. I learned something new in latex. – vijay Sep 22 at 5:25
  • I have tried the same with a different table, now I am getting an error. Package PGF math error. I have increased the number of rows by two, and I tried using your code – vijay Sep 22 at 5:53
  • @vijay Did you add rows that have non-numerical values? If so, you need to use \multicolumn{1}{c}{...} like e.g. \multicolumn{1}{c}{DROM} for those cells with non-numerical entries. (Of course, you can use l etc. instead of c, but not E. – Schrödinger's cat Sep 22 at 5:56
  • Can we change the color of the beta 4 to red when the ratio rho =1 – vijay Sep 22 at 8:02
  • 1
    @vijay Please ask a new question for this. Asking questions is free (and I actually do not understand your follow-up question). – Schrödinger's cat Sep 22 at 10:41

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.