左矩阵括号未正确呈现

左矩阵括号未正确呈现

我正在尝试将矩阵添加到现有文档中,这里这是原始文档的 Github 页面,这里是渲染后的版本。但是,当我在每隔一行添加矩阵时,矩阵的左括号不会被渲染。结果如下:

错误地渲染矩阵

我尝试过多种方式显示括号,但结果总是相同。这是我目前使用的代码:

Transpose \newline 
    \( \begin{bmatrix}
        a & b \\
        c & d \\
        e & f
    \end{bmatrix}^T \) & 
    \smallskip
    \( \begin{bmatrix}
        a & c & e \\
        b & d & f
    \end{bmatrix} \) \\

    Adjoint \newline    
    \( \begin{bmatrix}
        a & b \\
        c & d \\
        e & f
    \end{bmatrix}^\dagger \) & 
    \smallskip
    \( \begin{bmatrix}
        \overline{a} & \overline{c} & \overline{e} \\
        \overline{b} & \overline{d} & \overline{f}
    \end{bmatrix} \) \\

我不明白为什么这不能正确呈现,特别是因为它不是每一行都会发生。

预先感谢您的任何帮助。

编辑

完整工作文档

% Copyright (c) Microsoft Corporation. All rights reserved.
% Licensed under the MIT License.

%!TEX program=xelatex
% This cheatsheet is based on the template
% provided at https://gist.github.com/alexander-yakushev/c773543bf9a957749f79.
\documentclass[10pt,english,landscape]{article}
\usepackage{multicol}
\usepackage{calc}
\usepackage[landscape]{geometry}
\usepackage{color,graphicx,overpic}

% https://tex.stackexchange.com/a/192067
\usepackage{fontawesome}
  \newfontfamily{\FA}{[FontAwesome.otf]}

% Known issue in {fontspec}: https://github.com/wspr/fontspec/issues/312#issuecomment-342125206
% Since {fontspec} is included only when compiling with XeTeX, we guard
% our fix accordingly.
\usepackage{ifxetex}
    \ifxetex
        \let\latinencoding\relax
        \usepackage{fontspec}
        \setmainfont{Segoe UI}
        \setmonofont{Consolas}
    \fi

% \usepackage[T1]{fontenc}
% \usepackage[bitstream-charter]{mathdesign}
\usepackage[utf8]{inputenc}
\usepackage{url}
\usepackage{amsfonts}
\usepackage{array,booktabs}
\usepackage{textcomp}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{menukeys}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{tikz}
\usepackage{environ}
\usepackage{braket}

\usetikzlibrary{calc}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\geometry{top=1cm,left=1cm,right=1cm,bottom=1cm}

\pagestyle{empty} % Turn off header and footer

% \renewcommand\rmdefault{phv} % Arial
% \renewcommand\sfdefault{phv} % Arial

% Redefine section commands to use less space
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
  {-1ex plus -.5ex minus -.2ex}%
  {0.5ex plus .2ex}%x
  {\normalfont\large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
  {-1explus -.5ex minus -.2ex}%
  {0.5ex plus .2ex}%
  {\normalfont\normalsize\bfseries}}
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
  {-1ex plus -.5ex minus -.2ex}%
  {1ex plus .2ex}%
  {\normalfont\small\bfseries}}
\makeatother

\setcounter{secnumdepth}{0} % Don't print section numbers
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt plus 0.5ex}

\definecolor{TableHead}{rgb}{0.353, 0.329, 0.667}
\definecolor{TableRow}{rgb}{0.816, 0.812, 0.902}

\NewEnviron{keysref}[1]{
  % \begin{center}
  \smallskip
  \begin{tikzpicture}
      \rowcolors{1}{}{TableRow}

      \node (tbl) [inner sep=0pt] {
        \begin{tabular}{p{2.5cm}p{5.05cm}}
          \rowcolor{TableHead}
          \multicolumn{2}{l}{\normalsize\textbf{\color{white}{#1}}}\parbox{0pt}{\rule{0pt}{0.3ex+\baselineskip}}\\
          \BODY
          \arrayrulecolor{TableHead}\specialrule{.17em}{0em}{.2em}
        \end{tabular}};
      \begin{pgfonlayer}{background}
        \draw[rounded corners=2pt,top color=TableHead,bottom color=TableHead, draw=white]
        ($(tbl.north west)-(0,-0.05)$) rectangle ($(tbl.north east)-(0.0,0.15)$);
        \draw[rounded corners=2pt,top color=TableHead,bottom color=TableHead, draw=white]
        ($(tbl.south west)-(0.0,-0.11)$) rectangle ($(tbl.south east)-(-0.0,-0.02)$);
      \end{pgfonlayer}
    \end{tikzpicture}
  % \end{center}
}

% https://tex.stackexchange.com/a/102523
\newcommand{\forceindent}[1]{\leavevmode{\parindent=#1\indent}}

%% CUSTOM NOTATION %%

\newcommand{\qs}{Q\#}
\newcommand{\unixlike}{\hfill\faApple\faLinux}
\newcommand{\ctrllike}{\hfill\faWindows\faLinux}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\raggedright\

\Large{\qs~0.10 Language Quick Reference}

\footnotesize
\begin{multicols}{3}



  \begin{keysref}{Linear Algebra}
    Transpose \newline 
    \( \begin{bmatrix}
        a & b \\
        c & d \\
        e & f
    \end{bmatrix}^T \) & 
    \smallskip
    \( \begin{bmatrix}
        a & c & e \\
        b & d & f
    \end{bmatrix} \) \\

    Adjoint \newline    
    \( \begin{bmatrix}
        a & b \\
        c & d \\
        e & f
    \end{bmatrix}^\dagger \) & 
    \smallskip
    \( \begin{bmatrix}
        \overline{a} & \overline{c} & \overline{e} \\
        \overline{b} & \overline{d} & \overline{f}
    \end{bmatrix} \) \\
  \end{keysref}

\end{multicols}

\end{document} 

答案1

思考xcolor这是宏的魔法\rowcolors与使用的双重排版之间的某种冲突amsmath(如果我没记错的话,第一遍测量,第二遍生成输出)。下面是一个说明该问题的最小示例:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{amsmath}
\begin{document}
\rowcolors{1}{}{cyan}
\begin{tabular}{c}
AAA\\
\( \begin{bmatrix}                                                                                                                                            
a & b \\                                                                                                                                                      
c & d                                                                                                                                                         
\end{bmatrix} \)                                                                                                                                              
\end{tabular}
\end{document}

坏矩阵

以下是解决该问题的一个方法:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{amsmath}
\newbox\matrixbox
\sbox\matrixbox{\( \begin{bmatrix}
a & b \\
c & d
\end{bmatrix} \)}
\begin{document}
\rowcolors{1}{}{cyan}
\begin{tabular}{c}
AAA\\
\usebox\matrixbox
\end{tabular}
\end{document}

好矩阵

这里的重点是,如果在尝试创建表格之前对矩阵进行排版,问题就会消失。我 99% 肯定存在更好的方法,但目前我不知道它是什么。

相关内容