我有這個 MWE:
\documentclass[12pt,a4paper]{article}
\usepackage{nicematrix}
\begin{document}
\begin{enumerate}
\item
\begin{center}
$\begin{pNiceMatrix}[first-row,first-col]
& \{1,2\} & \{1,3\} & \{1,4\} & \{2,3\} & \{2,4\} & \{3,4\} \\
x_1 & 1 & 0 & 1 & 0 & 0 & 0 \\
x_2 & -1 & 0 & 0 & 1 & 1 & 0 \\
x_3 & 0 & 0 & 0 & -1 & 0 & 1 \\
x_4 & 0 & 0 & -1 & 0 & -1 & -1 \\
\end{pNiceMatrix}$
\end{center}
\item Two.
\item Three.
\end{enumerate}
\end{document}
不幸的是,矩陣之前的 1. 也居中。我怎樣才能避免這種情況?
答案1
快速而骯髒的駭客:
\documentclass[12pt,a4paper]{article}
\usepackage{nicematrix}
\begin{document}
\begin{enumerate}
\item \hfill $\begin{pNiceMatrix}[first-row,first-col]
& \{1,2\} & \{1,3\} & \{1,4\} & \{2,3\} & \{2,4\} & \{3,4\} \\
x_1 & 1 & 0 & 1 & 0 & 0 & 0 \\
x_2 & -1 & 0 & 0 & 1 & 1 & 0 \\
x_3 & 0 & 0 & 0 & -1 & 0 & 1 \\
x_4 & 0 & 0 & -1 & 0 & -1 & -1 \\
\end{pNiceMatrix}$\hfill\mbox{}
\item Two.
\item Three.
\end{enumerate}
\end{document}
答案2
一個簡單的解決方案是將矩陣放入 a 中minipage
:
\documentclass[12pt,a4paper]{article}
\usepackage{nicematrix}
\begin{document}
\begin{enumerate}
\item
\begin{minipage}{\linewidth}
\begin{center}
$\begin{pNiceMatrix}[first-row,first-col]
& \{1,2\} & \{1,3\} & \{1,4\} & \{2,3\} & \{2,4\} & \{3,4\} \\
x_1 & 1 & 0 & 1 & 0 & 0 & 0 \\
x_2 & -1 & 0 & 0 & 1 & 1 & 0 \\
x_3 & 0 & 0 & 0 & -1 & 0 & 1 \\
x_4 & 0 & 0 & -1 & 0 & -1 & -1 \\
\end{pNiceMatrix}$
\end{center}
\end{minipage}
\item Two.
\item Three.
\end{enumerate}
\end{document}