如果不使用 \hspace{…pt},如何使单独的方程式很好地对齐?

如果不使用 \hspace{…pt},如何使单独的方程式很好地对齐?

我添加了不同的 hspace 值来手动对齐它们

我的代码(不包括前言)(请不要评判):

\subsection{Inverse Hyperbolic Trigonometric Identities}
\raggedright\setlength{\parindent}{45pt}
    \begin{enumerate}[align=left,widest=a,labelindent=16mm,leftmargin=!]
    \incrvariable\x
    \setcounter{enumi}{\x}
    \item%194
        $
        \begin{aligned}[t]
        \sinh(\cosh^{-1}{x})=\sqrt{x^2-1} \hspace{20pt} &\text{Domain: } [1,\infty) \hspace{26.5pt} &&\text{Range: } [0,\infty)
        \end{aligned}
        $
    \incrvariable\x
    \item%195
        $
        \begin{aligned}[t]
        \cosh(\sinh^{-1}{x})=\sqrt{x^2+1} \hspace{20pt} &\text{Domain: } (-\infty,\infty) \hspace{10pt} &&\text{Range: } [1,\infty)
        \end{aligned}
        $
    \incrvariable\x
    \item%196
        $
        \begin{aligned}[t]
        \sinh(\tanh^{-1}{x})=\frac{x}{\sqrt{1-x^2}} \hspace{16.4pt} &\text{Domain: } (-1,1) \hspace{22pt} &&\text{Range: } (-\infty,\infty)
        \end{aligned}
        $
    \incrvariable\x
    \item%197
        $
        \begin{aligned}[t]
        \cosh(\tanh^{-1}{x})=\frac{1}{\sqrt{1-x^2}} \hspace{15.25pt} &\text{Domain: } (-1,1) \hspace{21.9pt} &&\text{Range: } [1,\infty)
        \end{aligned}
        $
    \incrvariable\x
    \item%198
        $
        \begin{aligned}[t]
        \tanh(\sinh^{-1}{x})=\frac{x}{\sqrt{1+x^2}} \hspace{16.72pt} &\text{Domain: } (-\infty,\infty) \hspace{9.5pt} &&\text{Range: } (-1,1)
        \end{aligned}
        $
    \incrvariable\x
    \item%199
        $
        \begin{aligned}[t]
        \tanh(\cosh^{-1}{x})=\frac{\sqrt{x^2-1}}{x} \hspace{15.48pt} &\text{Domain: } [1,\infty) \hspace{26.1pt} &&\text{Range: } [0,1)
        \end{aligned}
        $
    \end{enumerate}

\hspace{} 是重要(且烦人)的部分。

如何在不改变“枚举”和“对齐”或其他看起来几乎相同的东西的情况下改进我的代码?(跟踪经过的点的东西?)

或者在这里加上序言:(它很长)

\documentclass[12pt, twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage{indentfirst}
\usepackage[left=1.2in,right=1.2in,top=1in,bottom=1in]{geometry}
\usepackage{titling}
\usepackage{titlesec}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{compat=1.18, width=10cm}
\usepackage[fleqn]{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{newunicodechar}
\DeclareMathOperator{\sgn}{sgn}
\newunicodechar{ℤ}{\mathbb{Z}}
\newunicodechar{ℝ}{\mathbb{R}}
\usepackage{enumitem}
\usepackage{graphicx}
\setlength\mathindent{3cm}
\usepackage{etoolbox}
\usepackage{microtype}
\usepackage{array}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{romannum}
\usepackage{tocloft} %Change font size of TOC
%\renewcommand*{\arraystretch}{1.9}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newcolumntype{C}{>{$\displaystyle}c<{$}}
\renewcommand{\contentsname}{Table of Content}
\DeclareMathOperator{\sech}{sech}
\DeclareMathOperator{\csch}{csch}
\usepgfplotslibrary{fillbetween}

\AtBeginDocument{\addtocontents{toc}{\small}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Odd page number on the right 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\align@preamble{%
   &\hfil
\strut@
\setboxz@h{\@lign$\m@th\displaystyle{##}$}%
\ifmeasuring@\savefieldlength@\fi
\llap{\set@field}%
\tabskip\z@skip
   &\setboxz@h{\@lign$\m@th\displaystyle{{}##}$}%
\ifmeasuring@\savefieldlength@\fi
\rlap{\set@field}
\hfil
\tabskip\alignsep@
}

\titleformat{\section} 
{\normalfont\huge\bfseries}{\makebox[45pt][l]{\thesection}}{0pt}{} 
\titleformat{\subsection} 
{\normalfont\large\bfseries}{\makebox[45pt][l]{\thesubsection}}{0pt}{}
\titleformat{\subsubsection} 
{\normalfont\normalsize\bfseries}{\makebox[45pt][l]{\thesubsubsection}}{0pt}{}

\setlength{\droptitle}{-1em}

\setlength{\parindent}{45pt}

\title{\Huge{\textbf{Mathematics Directory}}}
\author{\Large{Zhiyuan Liu}}
\date{}

%\newcommand\X{0}
%\renewcommand\X{0} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\newvariable#1{\gdef#1{0}}
\def\addtovariable#1#2{\xdef#1{\number\numexpr#1+#2\relax}}
\def\incrvariable#1{\addtovariable#1{1}}

\newvariable\x

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

\begin{document}

\maketitle

\section{}
\subsection{Inverse Hyperbolic Trigonometric Identities}
\raggedright\setlength{\parindent}{45pt}
    \begin{enumerate}[align=left,widest=a,labelindent=16mm,leftmargin=!]
    \incrvariable\x
    \setcounter{enumi}{\x}
    \item%194
        $
        \begin{aligned}[t]
        \sinh(\cosh^{-1}{x})=\sqrt{x^2-1} \hspace{20pt} &\text{Domain: } [1,\infty) \hspace{26.5pt} &&\text{Range: } [0,\infty)
        \end{aligned}
        $
    \incrvariable\x
    \item%195
        $
        \begin{aligned}[t]
        \cosh(\sinh^{-1}{x})=\sqrt{x^2+1} \hspace{20pt} &\text{Domain: } (-\infty,\infty) \hspace{10pt} &&\text{Range: } [1,\infty)
        \end{aligned}
        $
    \incrvariable\x
    \item%196
        $
        \begin{aligned}[t]
        \sinh(\tanh^{-1}{x})=\frac{x}{\sqrt{1-x^2}} \hspace{16.4pt} &\text{Domain: } (-1,1) \hspace{22pt} &&\text{Range: } (-\infty,\infty)
        \end{aligned}
        $
    \incrvariable\x
    \item%197
        $
        \begin{aligned}[t]
        \cosh(\tanh^{-1}{x})=\frac{1}{\sqrt{1-x^2}} \hspace{15.25pt} &\text{Domain: } (-1,1) \hspace{21.9pt} &&\text{Range: } [1,\infty)
        \end{aligned}
        $
    \incrvariable\x
    \item%198
        $
        \begin{aligned}[t]
        \tanh(\sinh^{-1}{x})=\frac{x}{\sqrt{1+x^2}} \hspace{16.72pt} &\text{Domain: } (-\infty,\infty) \hspace{9.5pt} &&\text{Range: } (-1,1)
        \end{aligned}
        $
    \incrvariable\x
    \item%199
        $
        \begin{aligned}[t]
        \tanh(\cosh^{-1}{x})=\frac{\sqrt{x^2-1}}{x} \hspace{15.48pt} &\text{Domain: } [1,\infty) \hspace{26.1pt} &&\text{Range: } [0,1)
        \end{aligned}
        $
    \end{enumerate}
\end{document}

或者可能有人已经回答了。告诉我帖子。谢谢。

答案1

您有一组表格数据。一个简单的tabular就可以了。我会将每个数学表达式括在单独的分隔符之间\(...\)。如果您要呈现的数据很大,超出了一页,或者您只是希望在行之间某处有分页符,则需要longtable

以下示例基于longtable\everymath={\displaystyle}如果所有数学表达式都应采用显示样式,则取消注释。这可能需要通过增加arraystretch或来增加垂直间距extrarowheight

\documentclass{article}
\usepackage{array}
\usepackage{amsmath}
\usepackage{longtable}

\begin{document}
\section{Long table}
\begingroup
\newcounter{eqno}\setcounter{eqno}{190}
\newcommand\addeqno{\stepcounter{eqno}\theeqno.}
\setlength\extrarowheight{6pt}
% \everymath={\displaystyle}
%%%
\begin{longtable}[r]{@{}
        r
        >{\(}l<{\)}
        >{Domain: \(}l<{\)}
        >{Range: \(}l<{\)}
    @{}}
    \addeqno & \sinh(\cosh^{-1}{x})=\sqrt{x^2-1}           & [1,\infty)       & [0,\infty) \\
    \addeqno & \cosh(\sinh^{-1}{x})=\sqrt{x^2+1}           & (-\infty,\infty) & [1,\infty) \\
    \addeqno & \sinh(\tanh^{-1}{x})=\frac{x}{\sqrt{1-x^2}} & (-1,1)           & (-\infty,\infty) \\
    \addeqno & \cosh(\tanh^{-1}{x})=\frac{1}{\sqrt{1-x^2}} & (-1,1)           & [1,\infty) \\
    \addeqno & \tanh(\sinh^{-1}{x})=\frac{x}{\sqrt{1+x^2}} & (-\infty,\infty) & (-1,1) \\
    \addeqno & \tanh(\cosh^{-1}{x})=\frac{\sqrt{x^2-1}}{x} & [1,\infty)       & [0,1)
\end{longtable}
\endgroup
\end{document}

在此处输入图片描述


另一方面,使用enumerate,您必须模拟列。\makebox[<width>][<alignment>]{<content>}创建一个固定宽度的框,无论内容如何。因此,如果您水平放置三个这样的框,则可以实现所需的效果。缺点是必须手动设置每个框的宽度,一旦更改内容,可能需要重新调整。该包eqparbox提供了一个方便的宏,例如\eqmakebox[<label>][<alignment>}{<content>}。它的工作方式与常规宏完全相同makebox,但用户提供的不是宽度,而是标签。然后,根据每个标签的最长内容计算宽度。

longtable您可以看到这个解决方案需要更多的编码,但最终效果与/完全相同tabular

\documentclass{article}
\usepackage{enumitem}
\usepackage{eqparbox}
\usepackage{amsmath}

\begin{document}
\section{Enumerate}
\begin{enumerate}[
    align=left,
    widest=a,
    labelindent=10mm,
    leftmargin=!,
    before={\setcounter{enumi}{190}},
]
\item
    \eqmakebox[eq][l]{\(\sinh(\cosh^{-1}{x})=\sqrt{x^2-1}\)}%
    \quad
    \eqmakebox[do][l]{Domain:\([1,\infty)\)}%
    \quad
    \eqmakebox[ra][l]{Range:\([0,\infty)\)}
\item
    \eqmakebox[eq][l]{\(\cosh(\sinh^{-1}{x})=\sqrt{x^2+1}\)}%
    \quad
    \eqmakebox[do][l]{Domain: \((-\infty,\infty)\)}%
    \quad
    \eqmakebox[ra][l]{Range: \([1,\infty)\)}
\item
    \eqmakebox[eq][l]{\(\sinh(\tanh^{-1}{x}) = \frac{x}{\sqrt{1-x^2}}\)}%
    \quad
    \eqmakebox[do][l]{Domain: \((-1,1)\)}%
    \quad
    \eqmakebox[ra][l]{Range: \((-\infty,\infty)\)}
\item
    \eqmakebox[eq][l]{\(\cosh(\tanh^{-1}{x})=\frac{1}{\sqrt{1-x^2}}\)}%
    \quad
    \eqmakebox[do][l]{Domain: \((-1,1)\)}%
    \quad
    \eqmakebox[ra][l]{Range: \([1,\infty)\)}
\item
    \eqmakebox[eq][l]{\(\tanh(\sinh^{-1}{x})=\frac{x}{\sqrt{1+x^2}}\)}%
    \quad
    \eqmakebox[do][l]{Domain: \((-\infty,\infty)\)}%
    \quad
    \eqmakebox[ra][l]{Range: \((-1,1)\)}
\item
    \eqmakebox[eq][l]{\(\tanh(\cosh^{-1}{x})=\frac{\sqrt{x^2-1}}{x}\)}%
    \quad
    \eqmakebox[do][l]{Domain: \([1,\infty)\)}%
    \quad
    \eqmakebox[ra][l]{Range: \([0,1)\)}
\end{enumerate}
\end{document}

在此处输入图片描述

答案2

我能想到两种方法来实现你的排版目标:使用alignat*环境,以及使用longtable环境。

首先,alignat*基于的方法。观察:\hspace看不到任何单一的语句。

在此处输入图片描述

\documentclass[12pt, twoside]{article}
\usepackage[hmargin=1.2in,vmargin=1in]{geometry}

\usepackage{amsmath}
\allowdisplaybreaks

\newcounter{mycount}
\newcommand{\increment}{\refstepcounter{mycount}\themycount.}

\begin{document}

\setcounter{section}{4} % just for this example
\stepcounter{subsection}
\subsection{Inverse hyperbolic trigonometric identities}

\begin{alignat*}{4}
&&&&& \text{Domain} && \text{Range} \\[\jot] % "header line"
\increment &\qquad&
\sinh(\cosh^{-1}{x}) &= \sqrt{x^2-1} &\qquad&
[1,\infty) && [0,\infty) \\
\increment &&
\cosh(\sinh^{-1}{x}) &= \sqrt{x^2+1} &&
(-\infty,\infty) &\qquad&
[1,\infty) \\ \increment &&
\sinh(\tanh^{-1}{x}) &= \frac{x}{\sqrt{1-x^2}} &&
(-1,1) && (-\infty,\infty) \\[\jot] % "\jot" inserts a bit more vertical whitespace
\increment &&
\cosh(\tanh^{-1}{x}) &= \frac{1}{\sqrt{1-x^2}} &&
(-1,1) && [1,\infty) \\[\jot]
\increment &&
\tanh(\sinh^{-1}{x}) &= \frac{x}{\sqrt{1+x^2}} &&
(-\infty,\infty) && (-1,1) \\[\jot]
\increment &&
\tanh(\cosh^{-1}{x}) &= \frac{\sqrt{x^2-1}}{x} &&
[1,\infty) && [0,1)
\end{alignat*}
\end{document}

第二,longtable基于的方法。观察:仍然\hspace看不到任何指令。:-)

在此处输入图片描述

\documentclass[12pt, twoside]{article}
\usepackage[hmargin=1.2in,vmargin=1in]{geometry}

\usepackage{amsmath}
\allowdisplaybreaks

\usepackage{longtable,array,booktabs}
\newcounter{mycount}
\newcommand{\increment}{\refstepcounter{mycount}\arabic{mycount}.}
\newcolumntype{L}{>{$\displaystyle}l<{$}}
\newcolumntype{Z}{>{\refstepcounter{mycount}\arabic{mycount}.}l}

\begin{document}

\setcounter{section}{4}   % just for this example
\stepcounter{subsection}
\subsection{Inverse hyperbolic trigonometric identities}

\begingroup
\renewcommand\arraystretch{1.5}
\addtolength\tabcolsep{5pt}
\begin{longtable}{@{} Z LLLL @{}}

%% header
\multicolumn{1}{@{}l}{} &&& \textup{Domain} & \textup{Range} \\[1ex]
\endhead

%% body of table
& \sinh(\cosh^{-1}{x}) & \sqrt{x^2-1} &
  [1,\infty) & [0,\infty) \\
& \cosh(\sinh^{-1}{x}) & \sqrt{x^2+1} &
  (-\infty,\infty) & [1,\infty) \\ 
& \sinh(\tanh^{-1}{x}) & \frac{x}{\sqrt{1-x^2}} &
  (-1,1) & (-\infty,\infty) \\ \addlinespace
& \cosh(\tanh^{-1}{x}) & \frac{1}{\sqrt{1-x^2}} & 
  (-1,1) & [1,\infty) \\ \addlinespace
& \tanh(\sinh^{-1}{x}) & \frac{x}{\sqrt{1+x^2}} &
  (-\infty,\infty) & (-1,1) \\ \addlinespace
& \tanh(\cosh^{-1}{x}) & \frac{\sqrt{x^2-1}}{x} &
  [1,\infty) & [0,1) \\

\end{longtable}
\endgroup
\end{document}

相关内容