3

I'm trying to build a comparison table, I want to center the symbols vertically on the cells and I tried a lot of methods that I found here unsuccessfully.

This is the last code:

    \documentclass{report}
    \usepackage{color}
    \usepackage{array}
    \usepackage{rotating}
    \usepackage{diagbox}

    \begin{document}

      \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

      \newcommand{\myRed}[1]{{\color[RGB]{237,27,35}#1}}
      \newcommand{\myGreen}[1]{{\color[RGB]{0,166,79}#1}}
      \newcommand{\myBlue}[1]{{\color[RGB]{0,157,220}#1}}

      \newcommand{\amark}{\multicolumn{1}{c|}{\myBlue{\text{\sffamily *}}}}
      \newcommand{\cmark}{\multicolumn{1}{c|}{\myGreen{\text{\sffamily O}}}}
      \newcommand{\xmark}{\multicolumn{1}{c|}{\myRed{\text{\sffamily X}}}}

      \newcommand*\rot{\rotatebox{270}}

      \begin{sidewaystable}[ht] 
        \caption{Project comparison.} 
        \label{table:pComparison} 
        \centering 
        \scalebox{0.7}{
          \begin{tabular}{| C{50mm} | C{15mm} | C{15mm} | C{15mm} | C{15mm} | C{15mm} |}
            \hline 
            \diagbox[width=54mm, height=80mm]{\raisebox{20pt}{\hspace*{15mm}Projects}}{\raisebox{-87pt}{\rot{Features}}} & \rot{Feature 1} & \rot{Feature 2} & \rot{Feature 3} & \rot{Feature 4} & \rot{Feature 5} \\
            \hline 
            Project 1 & \xmark & \cmark & \xmark & \cmark & \cmark \\[5ex]
            \hline
            Project 2 & \cmark & \cmark & \cmark & \cmark & \xmark \\[5ex]
            \hline
            Project 3 & \xmark & \cmark & \amark & \cmark & \xmark \\[5ex]
            \hline
            Project 4 & \xmark & \cmark & \amark & \cmark & \xmark \\[5ex]
            \hline
            Project 5 & \xmark & \cmark & \xmark & \xmark & \cmark \\[5ex]
            \hline
            \hline
            My project & \cmark & \cmark & \cmark & \cmark & \cmark \\[5ex]
            \hline 
          \end{tabular}
        } 
      \end{sidewaystable} 

    \end{document}

And this is the result:

Table

Everything in the table is perfect, except that I need the symbols centered in the cells vertically and horizontally, also I would like to center the names of the projects at the first column.

Could you help me? Thanks in advance.

**EDIT: ** Sorry for not including the full code, I'm using a special template. I'm using MacTex and I'm compiling the latex using the command pdflatex table.tex

  • 1
    Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – Peter Grill Apr 26 '14 at 2:15
  • Use \newcommand*\rot{\rotatebox[origin=c]{270}}. – user11232 Apr 26 '14 at 2:24
  • @PeterGrill Sorry for include only a code snippet. Now everything is ok. – jceceniceros Apr 26 '14 at 2:40
  • @user1170251: Thanks. It is pretty close to a MWE. You are still missing the amsmath package. Best to just confirm by compiling the MWE you post here to make sure it is complete. – Peter Grill Apr 26 '14 at 2:43
  • @PeterGrill: Compiling the code of the answer one everything is complete :). Thanks you. – jceceniceros Apr 26 '14 at 2:51
3

Use \newcommand*\rot{\rotatebox[origin=c]{270}}:

\documentclass{article}
    \usepackage{rotating}
    \usepackage{diagbox,array,graphicx,xcolor,amssymb}

    \newcolumntype{C}[1]{>{\centering\arraybackslash} m{#1}}

    \newcommand{\myRed}[1]{{\color[RGB]{237,27,35}#1}}
    \newcommand{\myGreen}[1]{{\color[RGB]{0,166,79}#1}}
    \newcommand{\myBlue}[1]{{\color[RGB]{0,157,220}#1}}

    \newcommand*\rot{\rotatebox[origin=c]{270}}

    \newcommand{\amark}{\rot{\myBlue{\sffamily *}}}%
    \newcommand{\cmark}{\rot{\myGreen{$\checkmark$}}}%
    \newcommand{\xmark}{\rot{\myRed{\sffamily X}}}%
\begin{document}
    \begin{sidewaystable}[ht]
      \caption{Project comparison.}
      \label{table:pComparison}
      \centering
      \scalebox{0.7}{%
        \begin{tabular}{| C{50mm} | C{15mm} | C{15mm} | C{15mm} | C{15mm} | C{15mm} |@{}m{0pt}@{}} %
          \hline
          \diagbox[width=54mm, height=80mm]{\raisebox{20pt}{\hspace*{15mm}Projects}}{\raisebox{-87pt}{\rot{Features}}} & \rot{Feature 1} & \rot{Feature 2} & \rot{Feature 3} & \rot{Feature 4} & \rot{Feature 5} &\\
          \hline
          Project 1 & \xmark & \cmark & \xmark & \cmark & \cmark &\\[5ex]
          \hline
          Project 2 & \cmark & \cmark & \cmark & \cmark & \xmark &\\[5ex]
          \hline
          Project 3 & \xmark & \cmark & \amark & \cmark & \xmark &\\[5ex]
          \hline
          Project 4 & \xmark & \cmark & \amark & \cmark & \xmark &\\[5ex]
          \hline
          Project 5 & \xmark & \cmark & \xmark & \xmark & \cmark &\\[5ex]
          \hline
          \hline
          My project & \cmark & \cmark & \cmark & \cmark & \cmark &\\[5ex]
          \hline
        \end{tabular}
        }
    \end{sidewaystable} 
\end{document}

enter image description here

I have changed the \amark, \cmark and \xmark commands and added an additional (empty) column at the end to cure the bug with m column type.

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.