2

I'm trying to format this beautiful table given as an answer to Beautiful table samples. If you look at the third column, you can see that the unit is given in eV. I would like to add latex formulae with powers of ten to this column, but when I do, I get an error message:

Package PGF Math Error: Could not parse input '$10^6$' as a floating point number.

What can I do to insert latex math into this column? Thanks!

this beautiful table

Code:

\documentclass{article}

\usepackage{unicode-math}
\setmainfont[Mapping=tex-text, Numbers=OldStyle]{TeX Gyre Pagella}
\setmathfont[math-style=ISO]{TeX Gyre Pagella Math}

\usepackage{siunitx}
\usepackage{xcolor}
\usepackage{booktabs,colortbl, array}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.8}

\definecolor{rulecolor}{RGB}{0,71,171}
\definecolor{tableheadcolor}{gray}{0.92}
% Following is taken from Werner: https://tex.stackexchange.com/a/33761/3061
% and modified for my needs
%
% Command \topline consists of a (slightly modified)
% \toprule followed by a \heavyrule rule of colour tableheadcolor
% (hence, 2 separate rules)
\newcommand{\topline}{ %
        \arrayrulecolor{rulecolor}\specialrule{0.1em}{\abovetopsep}{0pt}%
        \arrayrulecolor{tableheadcolor}\specialrule{\belowrulesep}{0pt}{0pt}%
        \arrayrulecolor{rulecolor}}
% Command \midline consists of 3 rules (top colour tableheadcolor, middle colour black, bottom colour white)
\newcommand{\midtopline}{ %
        \arrayrulecolor{tableheadcolor}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{rulecolor}\specialrule{\lightrulewidth}{0pt}{0pt}%
        \arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
        \arrayrulecolor{rulecolor}}
% Command \bottomline consists of 2 rules (top colour
\newcommand{\bottomline}{ %
        \arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{0pt}%
        \arrayrulecolor{rulecolor} %
        \specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}%


\newcommand{\midheader}[2]{%
        \midrule\topmidheader{#1}{#2}}
\newcommand\topmidheader[2]{\multicolumn{#1}{c}{\textsc{#2}}\\%
                \addlinespace[0.5ex]}

\pgfplotstableset{normal/.style ={%
        header=true,
        string type,
        font=\addfontfeature{Numbers={Monospaced}}\small,
        column type=l,
        every odd row/.style={
            before row=
        },
        every head row/.style={
            before row={\topline\rowcolor{tableheadcolor}},
            after row={\midtopline}
        },
        every last row/.style={
            after row=\bottomline
        },
        col sep=&,
        row sep=\\
    }
}

\begin{document}
    \begin{table}
        \centering
        \caption{The bandgab of some semiconductors.}
        \pgfplotstabletypeset[normal,
                columns/eg/.style={
                column name={$E_{\textup{g}}$ (\si{\electronvolt})},
                dec sep align
        }
        ]{ %
        Material        & Symbol &  eg  & Type \\
        \topmidheader{5}{Elements}
        diamond         & C      & 5.46 & i \\
        silicon         & Si     & 1.12 & i \\
        germanium       & Ge     & 0.67 & i \\
        selenium        & Se     & 1.74 & d \\
        \midheader{5}{IV-IV Compounds}
        silicon carbide & SiC 3C & 2.36 & i \\
        silicon carbide & SiC 4H & 3.28 & i \\
        silicon carbide & SiC 6H & 3.03 & i \\
        \midheader{5}{III-V Compounds}
        indium phosphide& InP    & 1.27 & d \\
        indium arsenide & InAs   & 0.355& d \\
        gallium nitride & GaN    & 3.37 & d \\
        gallium arsenide& GaAs   & 1.42 & d \\
        aluminium nitride & AlN  & 6.2  & d \\
        }
\end{table}
\end{document}
  • 1
    Can you paste your code here for us to check? – percusse Sep 6 '16 at 14:19
  • 1
    First thought: You have $10^6$ where you should have 10^6. – Torbjørn T. Sep 6 '16 at 14:22
  • Don't load colortbl. Use the table option when loading xcolor. – cfr Sep 6 '16 at 14:45
  • Remove dec sep align ? – cfr Sep 6 '16 at 14:46
  • 1
    Also, instead of posting code that works, could you post code that generates the error you're referring to? That way we can easily see what you're doing. Further, if you want something like e.g. $5.46\cdot10^6$ for the diamond row, just type 5.46e6 instead of 5.46. – Torbjørn T. Sep 6 '16 at 20:04
1

I cannot see the problems. But there are three ways to achieve what you want


column name={$E_{\textup{g}}$ (\si{\mega\electronvolt})},


column name={$E_{\textup{g}}$ (\si{10^6\cdot\electronvolt})},


    diamond         & C      & 5.46e6 & i \\
    silicon         & Si     & 1.12e7 & i \\
    germanium       & Ge     & 0.67e8 & i \\
    selenium        & Se     & 1.74e9 & d \\

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.