I have a rather cramped looking table here showing the chance of a nurse touching a surface type given (s)he is doing a certain type of care. I would like to make a large curly bracket to the left of the rows with a vertical label (Care type), and one above the columns saying (Surface category). Any thoughts? Also I'm very open to any suggestion of how best to display this table at your discretion.

\usepackage{amsmath} % provides \text command
    &\text{Equipment}&\text{Patient}&\text{Hygiene products}&\text{Near-bed objects}&\text{Far-bed objects}\\
    \text{Direct Care}&\frac{49}{192}&\frac{170}{913}&\frac{18}{173}&\frac{79}{392}&\frac{21}{83}\\
    \text{Medication round}&\frac{23}{429}&\frac{23}{143}&\frac{7}{39}&\frac{50}{143}&\frac{10}{39}\\
    \text{Personal Care}&\frac{3}{89}&\frac{15}{89}&\frac{19}{89}&\frac{36}{89}&\frac{16}{89}\\

enter image description here

  • I assume that the table you show was not generated by the code you posted (which generates lots of syntax errors) undefined command \text and missing $ errors for every entry (as you can not have math in p columns) Mar 25 '13 at 18:47
  • You're right, it wouldn't compile, so I used mathjax on math.stackexchange.com. I don't understand why I need $ for every entry if I've put it in $$, could you clarify please?
    – HCAI
    Mar 25 '13 at 18:56
  • 3
    Please normalize your data. It's evil to force someone read this table.
    – percusse
    Mar 25 '13 at 19:27
  • I've done a minimalist edit on the code you've provided so that it can actually compile without lots of error messages
    – Mico
    Mar 25 '13 at 20:16
  • @percusse I have hiven your comment a thumbs up because I agree. When you say normalise... to what exactly are you referring? could you give me an example? I think in hindsight I will display this data pictorially as a bar graph.
    – HCAI
    Mar 26 '13 at 16:15

How about the following look. It dispenses with the need to ask your readers to crane their necks by 90 degrees, and it also provides a less cramped appearance. :-)

enter image description here

\begin{array}{@{} l *{5}{c} @{}}
\textbf{Care type} & \multicolumn{5}{c@{}}{\textbf{Surface category}}\\
&\text{Equipment} &\text{Patient}
&\text{Hygiene} &\text{Near-bed} &\text{Far-bed}\\
& & & \text{products} & \text{objects} & \text{objects}\\
\text{Direct Care}&\frac{49}{192}&\frac{170}{913}&\frac{18}{173}&\frac{79}{392}&\frac{21}{83}\\[0.7ex]
\text{Medication round}&\frac{23}{429}&\frac{23}{143}&\frac{7}{39}&\frac{50}{143}&\frac{10}{39}\\[0.7ex]
\text{Personal Care}&\frac{3}{89}&\frac{15}{89}&\frac{19}{89}&\frac{36}{89}&\frac{16}{89}\\[0.7ex]

Incidentally, I can't help but wonder what the purpose may be of expressing the numbers as exact fractions rather than as rounded decimal fractions (with either 3 or 4 digits of precision, say). I suspect that many potential readers might be better served with an approximate number such as 0.186 rather than with the exact value of 170/913.

  • This looks fantastic! Thank you for your nice work! In retrospect the decimals are easier to read.
    – HCAI
    Mar 25 '13 at 21:12
  • @HCAI - Glad you like the look. :-) If you do end up typesetting the numbers as decimal fractions, you could use a tabular environment rather than the array environment currently in use. As a benefit to switching to a tabular, you won't need to encase all the non-numeric cells with \text statements.
    – Mico
    Mar 25 '13 at 21:21
  • This is a very robust but versatile environment that you have provided! Again many thanks! By the way in your opinion how would you force latex to center this table if it got wider. Ie stop it running off the right hand margin.
    – HCAI
    Mar 25 '13 at 21:25
  • @HCAI - For information on "making room" for a table that's slightly wider than the text block see, e.g., tex.stackexchange.com/q/39435/5001.
    – Mico
    Mar 25 '13 at 21:52

enter image description here

a p column is a parbox so it takes you out of math mode. The edited question changed that to c but had the syntax of * incorrrect.

I added some braces (which requires a bit of hand tuning of the spaces) and opened up the display with \arraystretch.




\rotatebox[origin=c]{90}{\textbf{Care Type}}\left\{
    &\multicolumn{5}{c}{\textbf{Surface Category}}\\[-10pt]
    &\mbox{Equipment}&\mbox{Patient}&\mbox{Hygiene products}&\mbox{Near-bed objects}&\mbox{Far-bed objects}\\
    \mbox{Direct Care}&\frac{49}{192}&\frac{170}{913}&\frac{18}{173}&\frac{79}{392}&\frac{21}{83}\\
    \mbox{Medication round}&\frac{23}{429}&\frac{23}{143}&\frac{7}{39}&\frac{50}{143}&\frac{10}{39}\\
    \mbox{Personal Care}&\frac{3}{89}&\frac{15}{89}&\frac{19}{89}&\frac{36}{89}&\frac{16}{89}\\
  • Thank you very very much for your lovely work! I'm amazed every day by what LaTeX has to offer!
    – HCAI
    Mar 25 '13 at 21:13
  • 1
    And I'm amazed every day by what David has to offer in this forum. :) He is a true TeXpert! Mar 25 '13 at 22:29

this I find somewhat more pleasing (I'm not particularly fond of center alignment in tables). The look as well as the code might still need some refinement, though. I second Mico's suggestion: use 0.186 etc. instead. Makes things easier for both reader and typographer.

enter image description here


numerator-font = lmss,
denominator-font = lmss,
scale-factor = 1.333,
h-scale = 1

\footnotesize% = 10pt
    \begin{tabular}{l p{.12\textwidth} p{.12\textwidth} p{.12\textwidth} p{.12\textwidth} p{.12\textwidth}}
    & \mbox{\emph{surface category}}\\    

    \raisebox{-15pt}{\emph{care type}}&\raisebox{-15pt}{\textbf{equipment}}&\raisebox{-15pt}{\textbf{patient}}&\textbf{hygiene products}&\textbf{near-bed objects}&\textbf{far-bed objects}\\    

    {direct care}&\sfrac{49}{192}&\sfrac{170}{913}&\sfrac{18}{173}&\sfrac{79}{392}&\sfrac{21}{83}\\
    {medication round}&\sfrac{23}{429}&\sfrac{23}{143}&\sfrac{7}{39}&\sfrac{50}{143}&\sfrac{10}{39}\\
    {misc.}&\sfrac{4}{165}&\sfrac{19}{165}&\sfrac{8}{33}&\sfrac{10 }{33}&\sfrac{52}{165}\\
    {personal care}&\sfrac{3}{89}&\sfrac{15}{89}&\sfrac{19}{89}&\sfrac{36}{89}&\sfrac{16}{89}\\

As far as you asked, a suggestion: do not use curly brackets. Really, there is no need in them, just use a straight line and a column header instead. Also, a stack of fractions looks unreadable, and a / looks much like a visual noise. Check out this ctable example:

\usepackage{amsmath} % provides  command

\global\def\f#1/#2 {\ensuremath{^{#1}}&\ensuremath{_{#2}}}    
\global\def\row #1|#2|#3|#4|#5|#6 { #1&\f #2&\f #3&\f #4&\f #5&\f #6 }

\global\def\subhdr #1|#2|#3|#4|#5 {%

caption ={The chances of a nurse 
touching a surface type given (s)he is doing a certain type of care},
label = tab:1,
pos = ht,
width = 130mm,
mincapwidth = 160mm,
footerwidth = 130mm,
%doinside = \scriptsize
\tnote[a]{Comment: }
}{  \FL
&\multicolumn{10}{c}{Surface category}\NN
{Care type}    & \subhdr          {Equipment} |{Patient}|{Hygiene products}|{Near-bed objects}|{Far-bed objects} \ML
    \row Direct Care              |49/192     |170/913 |18/173          |79/392          |21/83 \\
    \row Housekeeping             |22/89      |7/89    |6/89            |35/89           |19/89 \\
    \row Mealtimes{\tmark[a]}     |0/{}       |6/55    |2/11            |31/55           |8/55 \\
    \row Medication round         |23/429     |23/143  |7/39            |50/143          |10/39 \\
    \row Misc.                    |4/165      |19/165  |8/33            |10/33           |52/165 \\
    \row Personal Care            |3/89       |15/89   |19/89           |36/89           |16/89 \\
    \row Overall                  |7/233      |34/233  |54/233          |80/233          |58/233   

enter image description here

Edit: An approach suggested by Daniel in Is it possible to use the pipe character, |, to separate cells in a table? was used in the \row definition.

  • This looks nice too, thank you very much! Fascinating, everybody has a different way of making a table! :) After all this, would you, as a reader prefer to see a graph of some sort perhaps?
    – HCAI
    Mar 26 '13 at 14:52
  • @HCAI: Editors/reviewers usually are not happy with the redundancy of information. Of course, the author can insist on including both a table and a picture, but it would be better if the picture illustrates something more to the reader - maybe a trend or whatever.
    – g.kov
    Mar 26 '13 at 15:05
  • I have this data in probability bar graph per care type. Perhaps the audience doesn't need to know the exact values but is happy with a pictorial comparison. Then of course reproducibility of results is harder for the reader, but nevermind. Again thank you for the table, it will always be useful for me to refer to a correctly created version. Regards
    – HCAI
    Mar 26 '13 at 16:14

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.