我正在尝试格式化这个漂亮的表格作为答案到漂亮的表格样本。如果您查看第三列,您会发现单位为 eV。我想将十的幂的 latex 公式添加到此列,但这样做时会收到错误消息:
Package PGF Math Error: Could not parse input '$10^6$' as a floating point number.
我该怎么做才能将乳胶数学插入此列?谢谢!
代码:
\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}