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

  • 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 05 '19 at 20:22
  • unfortunately I could not understand what you mean – Irreversible Sep 05 '19 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 05 '19 at 20:43
  • 3
    What you try so far? – Zarko Sep 05 '19 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 05 '19 at 21:00
  • See also https://tex.stackexchange.com/questions/339535/what-to-put-into-the-intersection-of-the-row-column-labels-of-a-table – John Kormylo Sep 05 '19 at 23:21

1 Answers1

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)
Mico
  • 506,678
  • 1
    Wonderful and Excellent!!! – Irreversible Sep 05 '19 at 21:34
  • 1
    I think the "open look" is very better... – Irreversible Sep 05 '19 at 21:36
  • @Irreversible -- I'm glad we agree. :-) – Mico Sep 05 '19 at 21:37
  • @Mico In my opinion, and based on some typography text books, the heading should be typeset with smaller fontsize. As it is now, I feel it is too much air. Also, the heading for columns 4, 7 and 10 would look better if aligned at the bottom of the head row (on two lines) – Sveinung Sep 05 '19 at 22:13
  • 1
    @Mico I'm glad we agree. :-) (Intentional citation theft :=) – Sveinung Sep 06 '19 at 06: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 06 '19 at 07:52
  • @Mico Really nice and readable. The textbook I read, was from the mid-fifties and heavily influenced by German typhography. The philosophy behind reduced font size of the heading is probably that the figures in the column is the most important information, and that a dominant heading (bold, colour, text heavy rules) take the focus from what is important. – Sveinung Sep 06 '19 at 09:33
  • @Mico, besides so much thanks to you for your help I have a question: If we insert the code in a two-column text file and if we wish to have the table in the top -center of a page, this code disagrees to us. Such a code constructs the table wherever is inserted and extends to other column. How can I overcome this problem?!!! – Irreversible Sep 11 '19 at 04:35
  • @Irreversible - You could encase everything between \[ and \] in a table* environment. – Mico Sep 11 '19 at 04:40
  • I thing I have to change array into tabular is it correct? – Irreversible Sep 11 '19 at 04:50
  • @Irreversible - Not if you keep the array inside \[ and \] instructions. – Mico Sep 11 '19 at 04:53
  • Thanks, I should try... – Irreversible Sep 11 '19 at 05:02
  • I modified the first line into \[ \begin{table*} \begin{array}{@{} l *{9}{c} @{}} \toprule and corresponding the end lines but I enforced with some problems – Irreversible Sep 11 '19 at 05:06
  • @Irreversible - No! It must be \begin{table*} \[ ... \] \end{table*}. Basically, what was previously a standalone display-math environment -- *including*[and]-- must be encased in atable*` environment. – Mico Sep 11 '19 at 05:12
  • Thank you so much.....so sorry for my mistake ..... – Irreversible Sep 11 '19 at 05:25
  • So sorry for interrupting you. I have so much tried with \centering after \begin{table} or \begin{center} before that, for putting the table in the center of the page's top but I could not reach to my goal. – Irreversible Sep 11 '19 at 05:39
  • @Irreversible -- I suggested \begin{table*} and \end{table*}, *not* \begin{table} and \end{table}. As long as you use \[ and \] (as is done in the code above!), there should be no need whatsoever for a \centering instruction or a center environment. If, for some reason, you prefer not to use \[ and \], there's not really any further role for me to play. – Mico Sep 11 '19 at 08:31
  • @Irreversible - Please see the addendum I just posted at the bottom of my answer. – Mico Sep 11 '19 at 08:35
  • @Irreversible -- By the way, one should never, ever place a table or table* environment inside a center environment. For sure, I did *not* suggest that you do so. – Mico Sep 11 '19 at 08:37
  • @Mico, thank you so much. I had made use of table* and for a short description , I wrote table. You are completely right. Thank you so much – Irreversible Sep 13 '19 at 14:46