问题:
尝试使用包对多项式除法问题进行本地排版polynomial
。
最小工作示例(MWE):
\documentclass[a4paper,11pt]{book}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\[
\begin{array}{l|l}
& 4x - 2 = K(x) \\ \cline{2-2}
N(x) = 2x^2 + x - 4 & 8x^3 + 0x^2 - 2x + 3 = T(x) \\ \cline{1-1}
& -(8x^3 + 4x^2 - 16x) \\ \cline{2-2}
& -4x^2 + 14x + 3 \\
& -(-4x^2 - 2x + 8) \\ \cline{2-2}
& 16x - 5 = R(x)
\end{array}
\]
\end{document}
电流输出:
期望输出:
该多项式应该:
- 整体左对齐
- 第一部分在右侧(左对齐),第二部分(居中对齐),第三部分(右对齐)
- 允许在右侧的每一行上显示文本
- 只有第二排有垂直线
答案1
有了tabular
环境和一些\multicolumn
命令:
(红线表示文本宽度,不会显示在实际文档中。)
\documentclass[a4paper,11pt]{book}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}
\begin{document}
\noindent
{\renewcommand{\arraystretch}{1.25}
\begin{tabular}{>{$}l<{$}>{$}l<{$}l}
& \phantom{-(} 4x - 2 = K(x) \\ \cline{2-2}
\multicolumn{1}{l|}{$N(x) = 2x^2 + x - 4$} & \phantom{-(}8x^3 + 0x^2 - 2x + 3 = T(x) \\ \cline{1-1}
& -(8x^3 + 4x^2 - 16x) \\ \cline{2-2}
& \multicolumn{1}{c}{$\phantom{-(}-4x^2 + 14x + 3$} & some text \\
& \multicolumn{1}{c}{$-(-4x^2 - 2x + 8)$} \\ \cline{2-2}
& \multicolumn{1}{r}{$16x - 5 = R(x)$} & some text
\end{tabular}}
\end{document}
使用更多\phantom
命令可以获得评论中请求的所需布局:
\documentclass{article}
\usepackage{array}
\begin{document}
{\renewcommand{\arraystretch}{1.25}
\begin{tabular}{>{$}l<{$}>{$}l<{$}l}
& \phantom{-(} 4x - 2 = K(x) \\ \cline{2-2}
\multicolumn{1}{l|}{$N(x) = 2x^2 + x - 4$} & \phantom{-(}8x^3 + 0x^2 - \phantom{1}2x + 3 = T(x) \\ \cline{1-1}
& -(8x^3 + 4x^2 - 16x) \\ \cline{2-2}
& \phantom{-(8x^3}-4x^2 + 14x + 3 & some text \\
& \phantom{8x^3}-(-4x^2 - \phantom{1}2x + 8) \\ \cline{2-2}
& \multicolumn{1}{r}{$16x - 5 = R(x)$} & some text
\end{tabular}}
\end{document}