2

It is easy to find a way to draw a table in latex.

Unfortunately, I have a special type of a table that has a particular shape.

I have several problems to construct it in latex however for gaining help from TexStackExchange community I draw it by Microsoft word.

I just wish to obtain the table's skeleton and its elements are not important and can be any thing. I mean, the two top rows of table are more important than other rows.

How can construct the table's form as below shaped:

enter image description here

6
  • 3
    Does the table have to look like a maze of prison-cell windows, or are you open (pun intended) to giving the table an open and inviting look?
    – Mico
    Sep 5, 2019 at 20:22
  • unfortunately I could not understand what you mean Sep 5, 2019 at 20:39
  • Must your table absolutely feature 8 horizontal lines and 11 vertical lines? The fine grid of horizontal and vertical lines looks very much like a prison cell window...
    – Mico
    Sep 5, 2019 at 20:43
  • 3
    What you try so far?
    – Zarko
    Sep 5, 2019 at 20:45
  • The following might serve as a point to start from: \documentclass{article} \usepackage{slashbox} \usepackage{cellspace} \setlength\cellspacetoplimit{10pt} \setlength\cellspacebottomlimit{10pt} \begin{document} \begin{tabular}{|c|Sc|Sc|} \hline \backslashbox{a}{b} & \multicolumn{2}{c|}{c}\\ \hline d & e & f\\ \hline \end{tabular} \end{document}
    – leandriis
    Sep 5, 2019 at 21:00

1 Answer 1

6

Here are two ways to construct the table.

  • The upper table strives for an open "look": no vertical lines and few but well-spaced horizontal lines. The reader's eyes are invited into the table and are free to roam around and take in all the information.

  • The lower table has an extremely closed look, mainly because of the overabundance of horizontal (8) and vertical (11) lines. It's not easy to move one's eyes from cell to cell.

It's up to you to decide which "look" works for you -- and, hopefully, for your readers as well. (Speaking for myself, I have a strong preference for the open look...)

enter image description here

enter image description here

\documentclass{article}
% Choose page parameters suitably:
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{array,booktabs}
\begin{document}

\[
%% First, the open "look"
\renewcommand\arraystretch{2.25}
\begin{array}{@{} l *{9}{>{\displaystyle}c} @{}}
\toprule
& \multicolumn{2}{c}{J^*(m)}     & t^*(m)     
& \multicolumn{2}{c}{J^{**}(m)}  & t^{**}(m)  
& \multicolumn{2}{c}{J^{***}(m)} & t^{***}(m) \\
\cmidrule(lr){2-3} \cmidrule(lr){5-6} \cmidrule(lr){8-9}
m & \frac{m-1}{m} & 2-\frac{m-1}{m} & m\pi 
  & \frac{m-3}{m} & 2-\frac{m-3}{m} & m\pi 
  & \frac{m-5}{m} & 2-\frac{m-5}{m} & m\pi \\
\midrule
1 & 0           & \frac{2}{1}=2 &  \pi & & & & & & \\
2 & \frac{1}{2} & \frac{3}{2}   & 2\pi & & & & & & \\
3 & \frac{2}{3} & \frac{3}{4}   & 3\pi & & & & & & \\
4 & \frac{3}{4} & \frac{5}{4}   & 4\pi & & & & & & \\
5 & \frac{4}{5} & \frac{6}{5}   & 5\pi & & & & 0 & \frac{10}{5}=2 & 5\pi \\
\bottomrule
\end{array}
\]

\[
%% Second, the very closed "look"
\renewcommand\arraystretch{2}
\begin{array}{| l | *{9}{>{\displaystyle}c|} }
\hline
& \multicolumn{2}{c|}{J^*(m)}     & t^*(m)     
& \multicolumn{2}{c|}{J^{**}(m)}  & t^{**}(m)  
& \multicolumn{2}{c|}{J^{***}(m)} & t^{***}(m) \\
\hline
m & \frac{m-1}{m} & 2-\frac{m-1}{m} & m\pi 
  & \frac{m-3}{m} & 2-\frac{m-3}{m} & m\pi 
  & \frac{m-5}{m} & 2-\frac{m-5}{m} & m\pi \\
\hline
1 & 0           & \frac{2}{1}=2 &  \pi & & & & & & \\
\hline
2 & \frac{1}{2} & \frac{3}{2}   & 2\pi & & & & & & \\
\hline
3 & \frac{2}{3} & \frac{3}{4}   & 3\pi & & & & & & \\
\hline
4 & \frac{3}{4} & \frac{5}{4}   & 4\pi & & & & & & \\
\hline
5 & \frac{4}{5} & \frac{6}{5}   & 5\pi & & & & 0 & \frac{10}{5}=2 & 5\pi\\
\hline
\end{array}
\]
\end{document}

Addendum to address @Sveinung's follow-up comment regarding desirable typographic features of the table: I fully agree with your observation that the second header row is currently too prominent, visually speaking; this is the case for both the "open" and the "closed" version. I didn't raise this issue in my initial answer because I had no idea if the OP's code, which contains lots of fraction terms, is for real or is meant as a mock-up. (One reason to believe it's mainly mock-up is that the information in columns 4, 7, and 10 is repeated verbatim.)

Assuming the fractional expressions in the second header row are for real, I can think of (at least!) 3 different, not mutually exclusive, approaches to improving the typography: (i) use a smaller font size for the entries in the second header row; (ii) switch from display-style to text-style fractions by using \tfrac instead of \frac; and (iii) use inline math notation; e.g., replace \frac{m-1}{m} and 2-\frac{m-1}{m} with 1-1/m and 1+1/m, respectively.

The third approach is implemented in the following table. Note that I've introduced inline-fraction notation not only in the header but in the body of the table as well.

enter image description here

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{array,booktabs}
\begin{document}

\[
%% Third, a much more compact (but still "open") look
\begin{array}{@{} l *{9}{c} @{}}
\toprule
m & \multicolumn{2}{c}{J^*(m)}     & t^*(m)
  & \multicolumn{2}{c}{J^{**}(m)}  & t^{**}(m)
  & \multicolumn{2}{c}{J^{***}(m)} & t^{***}(m) \\
\cmidrule(lr){2-3} \cmidrule(lr){5-6} \cmidrule(lr){8-9}
& 1-1/m & 1+1/m & m\pi
& 1-3/m & 1+3/m & m\pi
& 1-5/m & 1+5/m & m\pi \\
\midrule
1 & 0   & 2   &  \pi \\
2 & 1/2 & 3/2 & 2\pi \\
3 & 2/3 & 4/3 & 3\pi & 0   & 2   & 3\pi \\
4 & 3/4 & 5/4 & 4\pi & 1/4 & 7/4 & 4\pi \\
5 & 4/5 & 6/5 & 5\pi & 2/5 & 8/5 & 5\pi & 0 & 2 & 5\pi \\
\bottomrule
\end{array}
\]
\end{document}

Addendum, prompted by a follow-up question posted by the OP: To typeset the tabular material centered at the top of a page in a two-column document, you should encase all material from \[ to \] in a table* environment:

% ...
\begin{table*} % <-- new
\[
\begin{array}{@{} l *{9}{c} @{}}
\toprule
% (body of table)
\bottomrule
\end{array}
\]
\end{table*} % <-- new

% ... (remainder of document)
20
  • 1
    Wonderful and Excellent!!! Sep 5, 2019 at 21:34
  • 1
    I think the "open look" is very better... Sep 5, 2019 at 21:36
  • @Irreversible -- I'm glad we agree. :-)
    – Mico
    Sep 5, 2019 at 21:37
  • 1
    @Mico I'm glad we agree. :-) (Intentional citation theft :=)
    – Sveinung
    Sep 6, 2019 at 6:53
  • 1
    @Sveinung - I fully agree with your point that the second header row, in particular, is given far too much visual prominence. Please see the addendum I just posted, in which I address this issue, mainly by making the entire table much more compact than was the case initially.
    – Mico
    Sep 6, 2019 at 7:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .