移动方程式并对齐到外边距

移动方程式并对齐到外边距

我的文本宽度比较窄,所以有时我必须将浮动元素移到边距。对于图纸和表格,我使用\widefloat下面定义的命令

\documentclass[11pt]{scrbook}
\usepackage{lipsum}

\newcommand{\widefloat}[1]{%
\ifthispageodd{\makebox[\textwidth][l]{#1}}{\makebox[\textwidth][r]{#1}}}

\begin{document}

\lipsum[1-3]

\begin{table}[h]
\widefloat{\begin{tabular}{lll}
really really really really really & large large large large large & table table table table table \\
really really really really really & large large large large large & table table table table table \\
\end{tabular}}
\end{table}

\[
\frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y}\\
\]

\lipsum[1-3]

\begin{table}[h]
\widefloat{\begin{tabular}{lll}
really really really really really & large large large large large & table table table table table \\
really really really really really & large large large large large & table table table table table \\
\end{tabular}}
\end{table}

\[
\frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y}\\
\]

\lipsum[1]

\end{document}

在此处输入图片描述 在此处输入图片描述

然而,当我尝试将它应用到时\equation,我收到错误并且方程式转换成内联类型方程式。

有没有办法为方程式创建类似的命令?

答案1

您可以使用相同的方法;但最好在amsmath环境的帮助下拆分长方程式(split用于对齐部分,multline用于不对齐的情况)。

\documentclass[11pt]{scrbook}
\usepackage{lipsum}

\newcommand{\wideeq}[1]{%
  \ifthispageodd
    {\makebox[\textwidth][l]{$\displaystyle#1$}}
    {\makebox[\textwidth][r]{$\displaystyle#1$}}%
}

\begin{document}

\lipsum*[1]
\[
\wideeq{%
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y}
}
\]
\lipsum[2]
\clearpage
\lipsum*[1]
\[
\wideeq{%
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y}
}
\]
\lipsum[2]

\end{document}

在此处输入图片描述

请注意,切勿在显示的公式前留空行。这就是我\lipsum*在公式前使用的原因(它不会结束段落)。

使用\\内部\[...\]是没有意义的。

答案2

另外,您可以使用 KOMA-Script 的环境addmargin*来定义一个环境,该环境还使用外边距中的边距注释列。这样的环境可以用作表格、图形、方程式等的容器:

\documentclass[11pt]{scrbook}
\usepackage{lipsum}
\usepackage{showframe}% illustrate the text area, margin note column etc.

\newenvironment{wide}{%
  \begin{addmargin*}[0pt]{-\dimexpr\marginparsep+\marginparwidth\relax}
}{%
  \end{addmargin*}
}

\begin{document}

\lipsum*[1]
\begin{wide}
  \[
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y}
  \]
\end{wide}
\begin{table}[h]
  \begin{wide}
    \centering
    \begin{tabular}{@{}lll@{}}
      really really really really really & large large large large large & table table table table table \\
      really really really really really & large large large large large & table table table table table \\
    \end{tabular}
  \end{wide}
\end{table}

\lipsum[2]
\clearpage
\lipsum*[1]
\begin{wide}
  \[
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = \frac{x}{y} = 
  \frac{x}{y} = \frac{x}{y}
  \]
\end{wide}
\lipsum[2]

\end{document}

在此处输入图片描述

相关内容