与 xcolor 中的对齐和表格选项不兼容?

与 xcolor 中的对齐和表格选项不兼容?

让我们看看这个 MWE,它痛苦地从一个机构模板中缩减而来。它扼杀了align环境,除非我注释掉了包table中的选项xcolor。我想了解原因……并知道是否有解决方法,因为调用的xcolor进入机构模板...

\documentclass[twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{calc}
\usepackage{amsmath}
\usepackage{array}
\usepackage[dvipsnames,hyperref
    ,table  %%% comment this and all works
    ]{xcolor}
\usepackage{hyperref}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55

\newcommand{\twosidescontent}[3][0.65]{%
    \noindent\begin{tabular*}{\linewidth}{@{}@{\extracolsep{\fill}}m{#1\linewidth}c@{}}
        {#2} 
        &
        {\parbox[c][][c]{0.95\linewidth-#1\linewidth}{#3}}
    \end{tabular*}%
}
\begin{document}

\twosidescontent[0.7]{
    Given that 0.3~V is quite a low voltage, let's check with OFF state. 
    The check needed is just $V_{BE}<V_{BE_\mathit{on}}$:
    \[ V_{BE} = 0.3 - 0 = 0.3 < 0.7  \]
    which means it's effectively off. The result will be 
    \begin{align*}
        V_1 &= 0  \\ 
        I_1 &= 0
    \end{align*}
}{ 
    \includegraphics[width=0.95\linewidth]{example-image} %
}

\end{document}

它会给出环境错误align*

./p.tex:35: Misplaced \omit.
\math@cr@@@ ...@ \@ne \add@amps \maxfields@ \omit 
                                                  \kern -\alignsep@ \iftag@ ...
l.35 }

./p.tex:35: Misplaced \omit.
\math@cr@@@ ...@ \@ne \add@amps \maxfields@ \omit 
                                                  \kern -\alignsep@ \iftag@ ...
l.35 }

然后继续产生正确的输出(据我所知)。

继续后输出

如果我评论其中table的选项,xcolor它就会起作用。

问题:可以让align*环境正常运行table中的选项xcolor

答案1

我确实不知道问题是什么,但你从错误的角度看待这个问题。;-)

你只是不需要tabular*环境。

\documentclass[twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{calc}
\usepackage{amsmath}
\usepackage{array}
\usepackage[dvipsnames,hyperref,table]{xcolor}
\usepackage{hyperref}

\usepackage{showframe} % just for the example

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55

\newcommand{\twosidescontent}[3][0.65]{%
  \noindent\parbox{#1\linewidth}{#2}\hfill
  \parbox[c][][c]{0.95\linewidth-#1\linewidth}{#3}%
}
\begin{document}

\twosidescontent[0.7]{
    Given that 0.3~V is quite a low voltage, let's check with OFF state. 
    The check needed is just $V_{BE}<V_{BE_\mathit{on}}$:
    \[ V_{BE} = 0.3 - 0 = 0.3 < 0.7  \]
    which means it's effectively off. The result will be 
    \begin{align*}
        V_1 &= 0  \\ 
        I_1 &= 0
    \end{align*}
}{ 
    \includegraphics[width=0.95\linewidth]{example-image} %
}

\end{document}

在此处输入图片描述

相关内容