我不知道哪里出了问题。无论如何,pdf 看起来还不错
\documentclass[a4paper,12pt]{book}
\usepackage[margin=1.5cm]{geometry}
\usepackage{colortbl}
\usepackage{multicol}
\everymath=\expandafter{\the\everymath\displaystyle}
\renewcommand{\arraystretch}{2.2}
\begin{document}
\begin{tabular}{|m{0.55 \textwidth}|m{0.35 \textwidth}|}
\hline
\multicolumn{2}{|c|}{\rowcolor[gray]{0.8} {oscillations}} \\
\hline
\hline
$T = \frac{1}{f} $ & $ T=\frac{\Delta t}{N}$ \\
\hline
\end{tabular}
\end{document}
我用 xelatex 编译后
This is XeTeX, Version 3.1415926-2.2-0.9995.2 (TeX Live 2009/Debian)
entering extended mode
(./test.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, ibycus, monogreek, greek, ancientgreek, loaded.
(/usr/share/texmf-texlive/tex/latex/base/book.cls
Document Class: book 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/bk12.clo))
(/home/karathan/texmf/tex/latex/geometry/geometry.sty
(/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-texlive/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texmf-texlive/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texmf-texlive/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texmf-texlive/tex/xelatex/xetexconfig/geometry.cfg))
(/usr/share/texmf-texlive/tex/latex/colortbl/colortbl.sty
(/usr/share/texmf-texlive/tex/latex/tools/array.sty)
(/usr/share/texmf-texlive/tex/latex/graphics/color.sty
(/etc/texmf/tex/latex/config/color.cfg)
(/usr/share/texmf-texlive/tex/xelatex/xetex-def/xetex.def)))
(/usr/share/texmf-texlive/tex/latex/tools/multicol.sty) (./test.aux)
**... here is the problem**
*geometry* detected driver: pdftex
! Misplaced \noalign.
\rowcolor ->\noalign
{\ifnum 0=`}\fi \global \let \CT@do@color \CT@@do@color...
l.12 ...{|c|}{\rowcolor[gray]{0.8} {oscillations}}
\\
? [1] (./test.aux) )
Output written on test.pdf (1 page).
Transcript written on test.log.
答案1
里面\multicolumn
已经太晚了,\rowcolor
改变那个\cellcolor
应该没问题。
答案2
放在\rowcolor[gray]{0.8}
之前\multicolumn{2}{|c|}{oscillations}
。
\documentclass[a4paper,12pt]{book}
\usepackage[margin=1.5cm]{geometry}
\usepackage{colortbl}
\usepackage{multicol}
\everymath=\expandafter{\the\everymath\displaystyle}
\renewcommand{\arraystretch}{2.2}
\begin{document}
\begin{tabular}{|m{0.55 \textwidth}|m{0.35 \textwidth}|}
\hline
\rowcolor[gray]{0.8}\multicolumn{2}{|c|}{oscillations} \\
\hline
\hline
$T = \frac{1}{f} $ & $ T=\frac{\Delta t}{N}$ \\
\hline
\end{tabular}
\end{document}