Information and discussion about graphics, figures & tables in LaTeX documents.
pallav
Posts: 170 Joined: Wed Nov 12, 2008 5:53 pm
Post
by pallav » Mon Aug 20, 2012 11:58 am
I took a table help from this forum (titled Table Column Width Adjustment). I want to put a mathematical to every cell of the table
with a very nice look . I have tried with your tex but it gives error. Please help.
Code: Select all
\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{booktabs,multirow,amsmath,amssymb}
\usepackage{siunitx}
\begin{document}
\begin{table}[!ht]
\caption{Markov channel parameter settings}
\centering
\label{tab:markovchapara}
\begin{tabular}{
c
S[table-format=1.2]
@{~}
S[table-format=1.2]
S[table-format=1.3]
@{~}
S[table-format=1.3]
}\toprule
\multirow{2}{*}[-0.5ex]{Channel $j$} & \multicolumn{2}{c}{line1} & \multicolumn{2}{c}{line2} \\ \cmidrule(r){2-3}\cmidrule(l){4-5}
& {$p_j$} & {$q_j$} & {$\pi_{bj}$} & {$\pi_{ij}$} \\ \midrule
1 & $\Phi(N(t))=\frac{\alpha N(t)}{K(t)}$ & 0.4 & $\Phi(N(t))=\frac{\alpha N(t)}{K(t)}$ & 0.8 \\
2 & $\Phi(N(t))=\frac{\alpha N(t)}{K(t)}$ & 0.6 & $\Phi(N(t))=\frac{\alpha N(t)}{K(t)}$ & 0.75 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Last edited by
pallav on Tue Aug 21, 2012 3:31 pm, edited 1 time in total.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide : 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook : 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ : the first book about TikZ for perfect drawings in your LaTeX thesis
cgnieder
Site Moderator
Posts: 2000 Joined: Sat Apr 16, 2011 7:27 pm
Post
by cgnieder » Mon Aug 20, 2012 12:09 pm
You need to enclose
every cell in a
S
column into braces that is not a numerical input:
Code: Select all
\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{booktabs,multirow,amsmath,amssymb}
\usepackage{siunitx}
\begin{document}
\begin{table}[!ht]
\caption{Markov channel parameter settings}
\centering
\label{tab:markovchapara}
\begin{tabular}{
c
S[table-format=1.2]
@{~}
S[table-format=1.2]
S[table-format=1.3]
@{~}
S[table-format=1.3]
}\toprule
\multirow{2}{*}[-0.5ex]{Channel $j$} & \multicolumn{2}{c}{line1} & \multicolumn{2}{c}{line2} \\ \cmidrule(r){2-3}\cmidrule(l){4-5}
& {$p_j$} & {$q_j$} & {$\pi_{bj}$} & {$\pi_{ij}$} \\ \midrule
1 & {$\Phi(N(t))=\frac{\alpha N(t)}{K(t)}$} & 0.4 & {$\Phi(N(t))=\frac{\alpha N(t)}{K(t)}$} & 0.8 \\
2 & {$\Phi(N(t))=\frac{\alpha N(t)}{K(t)}$} & 0.6 & {$\Phi(N(t))=\frac{\alpha N(t)}{K(t)}$} & 0.75 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Since your columns 2 and 4 don't contain any numerical input at all but only maths you could also make them math columns:
Code: Select all
\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{booktabs,multirow,amsmath,amssymb}
\usepackage{siunitx}
\begin{document}
\begin{table}[!ht]
\caption{Markov channel parameter settings}
\centering
\label{tab:markovchapara}
\begin{tabular}{
c
>{$}c<{$}
@{~}
S[table-format=1.2]
>{$}c<{$}
@{~}
S[table-format=1.3]
}\toprule
\multirow{2}{*}[-0.5ex]{Channel $j$} & \multicolumn{2}{c}{line1} & \multicolumn{2}{c}{line2} \\ \cmidrule(r){2-3}\cmidrule(l){4-5}
& p_j & {$q_j$} & \pi_{bj} & {$\pi_{ij}$} \\ \midrule
1 & \Phi(N(t))=\frac{\alpha N(t)}{K(t)} & 0.4 & \Phi(N(t))=\frac{\alpha N(t)}{K(t)} & 0.8 \\
2 & \Phi(N(t))=\frac{\alpha N(t)}{K(t)} & 0.6 & \Phi(N(t))=\frac{\alpha N(t)}{K(t)} & 0.75 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Regards
pallav
Posts: 170 Joined: Wed Nov 12, 2008 5:53 pm
Post
by pallav » Mon Aug 20, 2012 12:20 pm
Thank you. Its works good. Would you please suggest me some other good looking style of table format specially used in thesis/books.
pallav
Posts: 170 Joined: Wed Nov 12, 2008 5:53 pm
Post
by pallav » Mon Aug 20, 2012 12:36 pm
How to warp the text if the a sentence is long in such as
Code: Select all
\multicolumn{2}{c}{Markov channel parameter settings 1}
instead of
cgnieder
Site Moderator
Posts: 2000 Joined: Sat Apr 16, 2011 7:27 pm
Post
by cgnieder » Mon Aug 20, 2012 12:41 pm
If I'm guessing right you want something like this:
Code: Select all
\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{booktabs,multirow,amsmath,amssymb}
\usepackage{siunitx}
\begin{document}
\begin{table}[!ht]
\caption{Markov channel parameter settings}
\centering
\label{tab:markovchapara}
\begin{tabular}{
c
>{$}c<{$}
@{~}
S[table-format=1.2]
>{$}c<{$}
@{~}
S[table-format=1.3]
}\toprule
\multirow{2}{*}[-0.5ex]{Channel $j$} & \multicolumn{2}{p{9em}}{A long, long, long line, that is broken} & \multicolumn{2}{c}{line2} \\ \cmidrule(r){2-3}\cmidrule(l){4-5}
& p_j & {$q_j$} & \pi_{bj} & {$\pi_{ij}$} \\ \midrule
1 & \Phi(N(t))=\frac{\alpha N(t)}{K(t)} & 0.4 & \Phi(N(t))=\frac{\alpha N(t)}{K(t)} & 0.8 \\
2 & \Phi(N(t))=\frac{\alpha N(t)}{K(t)} & 0.6 & \Phi(N(t))=\frac{\alpha N(t)}{K(t)} & 0.75 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Regards
pallav
Posts: 170 Joined: Wed Nov 12, 2008 5:53 pm
Post
by pallav » Mon Aug 20, 2012 12:43 pm
If I use the last, the table goes out from the page due to its long width. So I want to put the text wraped. Also if we use some long math expression, the same problem occurs. So I need to modify the code so the the long text/math expessions will come in two or more lines.
cgnieder
Site Moderator
Posts: 2000 Joined: Sat Apr 16, 2011 7:27 pm
Post
by cgnieder » Mon Aug 20, 2012 12:47 pm
Would you please add a
minimal working example that shows what exactly goes wrong? Otherwise answering is more of a guessing than actually giving you good advice.
Regards
pallav
Posts: 170 Joined: Wed Nov 12, 2008 5:53 pm
Post
by pallav » Mon Aug 20, 2012 1:13 pm
I am writing you in brief what I exactly need with the help of a table. The style of the table looks like the upper table attached herewith and the cells to be filled up by mathematical expression/text as like the lower part of the table. Also I need the whole table in \scriptsize. Hope I am able to share about my problem.
Attachments
table.JPG (84.98 KiB) Viewed 6915 times
cgnieder
Site Moderator
Posts: 2000 Joined: Sat Apr 16, 2011 7:27 pm
Post
by cgnieder » Mon Aug 20, 2012 1:50 pm
Is this a screenshot from one of your tables? Or is that how you want your table to look like? Either way, could you please add a
minimal working example (i.e. some actual code), anyway, that shows what you mean by
the table goes out from the page due to its long width
Regards
pallav
Posts: 170 Joined: Wed Nov 12, 2008 5:53 pm
Post
by pallav » Mon Aug 20, 2012 2:01 pm
Thank you for your help, I have made the whole table to script size. Thanks a lot again, it's really appreciated.
Would you please tell me how to increase the distance of two adjacent rows and two adjacent columns a little bit more?