0

Hello I have tired to build this table attached enter image description here

following code is my try..I do not know how to bring the same setting

 \documentclass[preprint,12pt,authoryear]{elsarticle}

 \usepackage{epsfig}
 \usepackage{graphicx}
\usepackage{placeins}
\usepackage{siunitx}

\usepackage{amssymb}
 \usepackage{amsthm}
 \usepackage{amsmath}
 \usepackage{tabularx}
 \usepackage{siunitx}
\usepackage{booktabs} % <-- To get prettier rules in tables
\usepackage{caption} % <-- To set caption width etc.
\begin{document} 
\begin{table}
  \centering
  \captionsetup{width=10cm}
  \caption{Silicon Nitride Height Measurements}
  \label{tab:2}
  \begin{tabular}{l *{4}{S[table-format=4.0]}}
    \toprule
           {Transformation temperatures} & {Transformation constants}&{Maximum residual strain} &{Effect modulus}\\
            & \si{nm} &  &\si{nm}\\
    \midrule
     $M_f$  &       145 &        55 &        140& 55 \\
     $M_s$     &      130 &        50&        135& 60\\
     $A_f$    &       145 &        60&        125& 60\\
     $A_s$  &       190 &        90 &        230& 100\\
         &  185 &        85&        180&  75\\
          &195 &        85&        200& 65\\
    \bottomrule
  \end{tabular}
\end{table}
\FloatBarrier 
\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
Mohammad
  • 966
  • Please can you complete your code so that it can be compiled? – cfr Mar 20 '16 at 03:13
  • @cfr You should be able to compile that without any problem. – Mohammad Mar 20 '16 at 03:14
  • 1
    If I copy-paste your code into an empty file and compile I guarantee you it will not work. I would stake my hat on it. – cfr Mar 20 '16 at 03:17
  • @cfr try now! let me know what would be happen to your hair – Mohammad Mar 20 '16 at 03:20
  • Maybe you might need a \begin{document} and an \end{document} for this to suffice as a MWE? And I think that @cfr was willing to lose his hat, not his hair ;) – A Feldman Mar 20 '16 at 03:48
  • @AFeldman I think I initially said hair pins and then upped the stakes to a hat. But no, I never offered my hair. – cfr Mar 20 '16 at 03:50
  • @ Cfr following what AFeldman suggested I did! the main issue is that I do not have enough experience in formatting complicated table like above. can you help me to fix that?I need to study your answers. – Mohammad Mar 20 '16 at 03:52
  • Add a \ before begin{document} I tried changing it but the edit is waiting on peer review, I compiled it. It looks pretty good. I don't see a problem really. – A Feldman Mar 20 '16 at 04:08
  • @A Feldman, look at the image of table that I have in my original question. I want to have that. I can make that. can you modify the code accordingly? – Mohammad Mar 20 '16 at 04:09
  • Best of luck in figuring this out. – A Feldman Mar 20 '16 at 04:36
  • 1
    You have four answers now and every one states that the question is unclear. Please try to be as precise as possible for your future questions. – Johannes_B Mar 20 '16 at 08:13
  • Is this an example of an opinion based question? – A Feldman Mar 20 '16 at 13:29

4 Answers4

2

I reduced your MWE to the really absolute necessary and hope that I have guessed right what belongs to what.

The trick used here for the heading lines is to use a new line when you want to "break" the heading.

\documentclass[border=2mm]{standalone}
\usepackage{siunitx}
\usepackage{booktabs} % <-- To get prettier rules in tables
\begin{document}
    \begin{tabular}{
        l
        S[table-format=3]
        S[table-format=2]
        S[table-format=3]
        S[table-format=3]
    }
        \toprule
                & {Transformation}
                        & {Transformation}
                                & {Maximum}
                                        & {Effect} \\
                & {temperatures}
                        & {constants}
                                & {residual strain}
                                        & {modulus} \\
                & {\si{\nm}}
                        &       & {\si{\nm}}
                                        &     \\
            \midrule
        $M_f$   & 145   & 55    & 140   & 55  \\
        $M_s$   & 130   & 50    & 135   & 60  \\
        $A_f$   & 145   & 60    & 125   & 60  \\
        $A_s$   & 190   & 90    & 230   & 100 \\
                & 185   & 85    & 180   & 75  \\
                & 195   & 85    & 200   & 65  \\
            \bottomrule
    \end{tabular}
\end{document}

image showing the result of above code

Stefan Pinnow
  • 29,535
  • thanks but look at the image of table that I am looking for, this version is a simplified of what I am looking for based on my initial try. Can you adjust that to the image of table that posted in my question? – Mohammad Mar 20 '16 at 06:26
  • 2
    Do you like that some one retype table on the image (instead of you)? – Zarko Mar 20 '16 at 06:56
2

Your question is not clear at all. Presented image is completely different from your MWE ... How to make nice table from your MWE, you already have two nice answers, in case, that you like to retype images, the following MWE might be of help:

\documentclass[border=3mm]{standalone}
\usepackage{siunitx}
\usepackage{mathtools}
\usepackage{booktabs,makecell} % <-- To get prettier rules in tables
    \renewcommand\theadfont{\bfseries}

\begin{document}
    \begin{tabular}{*{4}{c}}
        \toprule
\thead[b]{column head}
    &   \thead[b]{two line\\
                  column head}
        &   \thead[b]{two line\\
                      column head}
            &   \thead[b]{two line\\
                          column head}  \\
    \midrule
$\begin{aligned}
    D_s & = \SI{67e-3}{MPa} \\
    D_m & = \dots           \\
\Theta  & = \dots           \\
\vphantom{A_f}
 \end{aligned}$
    &
    $\begin{aligned}
        M_f & = \SI{9}{\degreeCelsius}  \\
        M_s & = \dots                   \\   
        A_f & = \dots                   \\   
        A_s & = \dots                    
     \end{aligned}$
        &
        $\begin{aligned}
            C_M & = \SI{8}{MPA/\degreeCelsius}  \\
          \dots & = \dots                       \\
          \dots & = \dots                       \\
          \dots & = \dots                       
         \end{aligned}$
            &
            $\begin{aligned}
              \dots & = \dots   \\
              \dots & = \dots   \\
              \vphantom{A_f}    \\
              \vphantom{A_f}    
             \end{aligned}$     \\
            \bottomrule
    \end{tabular}
\end{document}

enter image description here

In my MWE I didn't bother with table content details (that is easy to write in appropriate place) nor with table caption.

Zarko
  • 296,517
1
\documentclass[preprint,12pt,authoryear]{elsarticle}
\usepackage{epsfig}
\usepackage{graphicx}
\usepackage{placeins}
\usepackage{siunitx}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{booktabs} % <-- To get prettier rules in tables
\usepackage{caption} % <-- To set caption width etc.
\begin{document}
\begin{table}
\centering
\captionsetup{width=10cm}
\caption{Silicon Nitride Height Measurements}
\label{tab:2}
\begin{tabular}{*{2}{p{3cm}}p{2cm}p{2cm}r}
\toprule
{Transformation Temperatures} & {Transformation Constants}&{Maximum Residual} &{Effect Modulus}& ?\\
& $\si{nm}$ & strain&$\si{nm}$&\\
\midrule
$M_f$  &       145 &        55 &        140& 55 \\
$M_s$     &      130 &        50&        135& 60\\
$A_f$    &       145 &        60&        125& 60\\
$A_s$  &       190 &        90 &        230& 100\\
&  185 &        85&        180&  75\\
&195 &        85&        200& 65\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

reqtbl

murugan
  • 1,669
1

look at the image of table that I have in my original question. I want to have that.

Unfortunately, the table shown in the screenshot and the code for the sample table do not correspond closely. Hence, it is not clear which formatting-related aspects of the table in the screenshot you wish to replicate. Is it the sans-serif font (and, if so, which one?), is it the bold lettering of the table caption and cell headers, or is something else still?

The following code focuses on bold-facing the caption and cell headers. It also uses a tabularx environment instead of a tabular environment, with the width of the tabularx environment set to \textwidth -- it doesn't get any wider. Even so, observe that it's necessary to truncate some of the words in the header row.

enter image description here

\documentclass[preprint,12pt,authoryear]{elsarticle}

 \usepackage[font=bf,skip=0.5\baselineskip]{caption}
 \usepackage{siunitx,booktabs}
 \usepackage{tabularx}
 \newcolumntype{C}{>{\centering\arraybackslash}X}
 \newcommand\mc[1]{\multicolumn{1}{C}{#1}} % handy shortcut macro

\begin{document} 
\begin{table}
  \caption{Silicon Nitride Height Measurements}
  \label{tab:2}
  \setlength\tabcolsep{4pt} % default: 6pt
  \sisetup{table-format=3.0}
  \begin{tabularx}{\textwidth}{@{} l *{4}{S} @{}}
  \toprule 
  \bfseries [Header] &
  \mc{\bfseries Transform.\ temperature} & 
  \mc{\bfseries Transform.\ constant} &
  \mc{\bfseries Max.\ resid.\ strain} &
  \mc{\bfseries Effect modulus}\\
  & [\si{nm}] & & [\si{nm}] \\
    \midrule
     $M_f$  &  145 & 55 & 140&  55 \\
     $M_s$  &  130 & 50 & 135&  60 \\
     $A_f$  &  145 & 60 & 125&  60 \\
     $A_s$  &  190 & 90 & 230& 100 \\
            &  185 & 85 & 180&  75 \\
            &  195 & 85 & 200&  65 \\
    \bottomrule
  \end{tabularx}
\end{table} 
\end{document}
Mico
  • 506,678