我正在尝试使用 align 和朋友来排版某些内容——它位于源和数学之间。
对齐要求是将“=”和模式排列在 Haskell 类方程的左侧。
不相交的要求是第一行(类型)不应影响其余行。
我想到的代码(看起来可以忍受)是糟糕的 LaTeX!
有人可以帮忙改进它吗?
[这些\qquads
是为了将其推向左边,我无法让 fleqn 工作。lipsum 用于验证列拟合]
% Intended LaTeX compiler: pdflatex
\documentclass[conference,a4paper]{IEEEtran}
\usepackage{egreg}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{lipsum}
\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle #2}}}}
\newcommand{\gufx}[1] {\scalemath{1.1}{\text{\,\guilsinglleft{#1}\guilsinglright}}\,\,}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand{\cc}{\mathbin{\!::\!}}
\newcommand{\pp}{\mathrel{\,+\!\!\!+\,}}
%% \newcommand{\sub}{\scalebox{0.6}[1.0]{\( - \)}}
%% \newcommand{\plus}{\scalebox{0.8}{\( + \)}}
\date{}
\title{Some Title}
\begin{document}
\author{\IEEEauthorblockN{John Doe}
}
\maketitle
\thispagestyle{plain}
\pagestyle{plain}
\begin{abstract}
Bla Bla
\end{abstract}
\begin{IEEEkeywords}
Key Key
\end{IEEEkeywords}
\section{Top level head}
\label{sec:org7975432}
\lipsum[1]
\begingroup
\addtolength{\jot}{-.25em}
\small
\begin{alignat*}{6}
\begin{alignedat}{6}
&c&&:\,\,&& \mathbb{N} \rightarrow \mathbb{N} \rightarrow \mathbb{N}&&\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\;\\
\end{alignedat}\\[1em]
\begin{alignedat}{40}
&0 &&\gufx{c} &&(r{+}1) &&= &&\,0\\
&n &&\gufx{c} &&0 &&= &&\,1\\
&(n{+}1) &&\gufx{c} &&r &&= &&\,n \gufx{c} \! r + n \gufx{c} \!(r{-}1)&&\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad
\end{alignedat}
\end{alignat*}
\lipsum[2]
\begin{alignat*}{6}
\begin{alignedat}{6}
&ce&&:[t] \rightarrow \mathbb{N} \rightarrow [[t]]\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\\
\end{alignedat}\\[1.3em]
\begin{alignedat}{40}
&\,[\,\,] &&\gufx{ce}&&(r{+}1)&&= [\,\,]\\
&\,xs &&\gufx{ce} &&0 &&= [[\,\,]]\\
&\,(x\cc xs) &&\gufx{ce} &&r &&= xs \gufx{ce}\! r {\mathrel{\pp}} [x\cc y \mid y \in (xs \gufx{ce} (r{-}1))] \qquad\qquad\qquad\qquad\qquad\qquad\quad
\end{alignedat}
\end{alignat*}
\endgroup
\lipsum[1-4]
\end{document}
在 Zarko 回答之后添加。
我试过了fleqn*
。flalign*
都没用
答案1
使用不太可怕的输入IEEEeqnarraybox
(参见手册)和“肮脏的伎俩”
\documentclass[conference,a4paper]{IEEEtran}
\usepackage[T1]{fontenc}
\usepackage[fleqn]{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{newtx}
\usepackage{lipsum}
\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle #2}}}}
\newcommand{\gufx}[1] {\mathrel{\scalemath{1.1}{\text{\guilsinglleft{#1}\guilsinglright}}}}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand{\cc}{\mathbin{\!::\!}}
\newcommand{\pp}{\mathrel{\,+\!\!\!+\,}}
%% \newcommand{\sub}{\scalebox{0.6}[1.0]{\( - \)}}
%% \newcommand{\plus}{\scalebox{0.8}{\( + \)}}
\newenvironment{leftdisplay}[1][\normalsize]
{$$\hspace{0pt}\begin{minipage}{\displaywidth}#1}
{\end{minipage}\hspace{1000pt minus 1fil}$$}
\begin{document}
\author{\IEEEauthorblockN{John Doe}}
\title{Some Title}
\date{}
\maketitle
\begin{abstract}
Bla Bla
\end{abstract}
\begin{IEEEkeywords}
Key Key
\end{IEEEkeywords}
\section{Top level head}
\label{sec:org7975432}
\lipsum[1]
\begin{leftdisplay}
\begin{IEEEeqnarraybox}{lClCl}
\IEEEeqnarraymulticol{5}{l}{%
c\colon\mathbb{N} \rightarrow \mathbb{N} \rightarrow \mathbb{N}%
} \\[1ex]
0 & \gufx{c} & (r{+}1) & = & 0 \\
n & \gufx{c} & 0 & = & 1 \\
(n{+}1) & \gufx{c} & r & = & n \gufx{c} \! r + n \gufx{c} \!(r{-}1)
\end{IEEEeqnarraybox}
\end{leftdisplay}
\lipsum[2][1-5]
\begin{leftdisplay}[\small]
\begin{IEEEeqnarraybox}{lClCl}
\IEEEeqnarraymulticol{5}{l}{ce\colon [t] \rightarrow \mathbb{N} \rightarrow [[t]]} \\[1.5ex]
[\,\,] & \gufx{ce} & (r{+}1) & = & [\,\,]\\
xs & \gufx{ce} & 0 & = & [[\,\,]]\\
(x\cc xs) & \gufx{ce} & r & = & xs \gufx{ce} r {\mathrel{\pp}}
[x\cc y \mid y \in (xs \gufx{ce} (r{-}1))]
\end{IEEEeqnarraybox}
\end{leftdisplay}
\lipsum[1-5]
\end{document}
环境leftdisplay
有一个可选参数来设置较小的字体。另一方面,newtx
第二个显示器实际上不需要\small
:
和使用,而不是IEEEeqnarray
。您可以在 的可选参数中添加设置。这里我注释掉了(但结果肯定是质量较低)。可能部分的数量应该有所不同。IEEEeqnarraybox
\IEEEeqnarrayjot
\jot
leftdisplay
newtx
\small
\documentclass[conference,a4paper]{IEEEtran}
\usepackage[T1]{fontenc}
\usepackage[fleqn]{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{graphicx}
%\usepackage{newtx}
\usepackage{lipsum}
\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle #2}}}}
\newcommand{\gufx}[1] {\mathrel{\scalemath{1.1}{\text{\guilsinglleft{#1}\guilsinglright}}}}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand{\cc}{\mathbin{\!::\!}}
\newcommand{\pp}{\mathrel{\,+\!\!\!+\,}}
%% \newcommand{\sub}{\scalebox{0.6}[1.0]{\( - \)}}
%% \newcommand{\plus}{\scalebox{0.8}{\( + \)}}
\newenvironment{leftdisplay}[1][\normalsize]
{$$\hspace{0pt}\begin{minipage}{\displaywidth}#1}
{\end{minipage}\hspace{1000pt minus 1fil}$$}
\begin{document}
\author{\IEEEauthorblockN{John Doe}}
\title{Some Title}
\date{}
\maketitle
\begin{abstract}
Bla Bla
\end{abstract}
\begin{IEEEkeywords}
Key Key
\end{IEEEkeywords}
\section{Top level head}
\label{sec:org7975432}
\lipsum[1]
\begin{leftdisplay}[\addtolength\IEEEnormaljot{-0.25em}]
\begin{IEEEeqnarraybox}{lClCl}
\IEEEeqnarraymulticol{5}{l}{%
c\colon\mathbb{N} \rightarrow \mathbb{N} \rightarrow \mathbb{N}%
} \\[1ex]
0 & \gufx{c} & (r{+}1) & = & 0 \\
n & \gufx{c} & 0 & = & 1 \\
(n{+}1) & \gufx{c} & r & = & n \gufx{c} \! r + n \gufx{c} \!(r{-}1)
\end{IEEEeqnarraybox}
\end{leftdisplay}
\lipsum[2][1-5]
\begin{leftdisplay}[\small\addtolength\IEEEnormaljot{-0.25em}]
\begin{IEEEeqnarraybox}{lClCl}
\IEEEeqnarraymulticol{5}{l}{ce\colon [t] \rightarrow \mathbb{N} \rightarrow [[t]]} \\[1.5ex]
[\,\,] & \gufx{ce} & (r{+}1) & = & [\,\,]\\
xs & \gufx{ce} & 0 & = & [[\,\,]]\\
(x\cc xs) & \gufx{ce} & r & = & xs \gufx{ce} r {\mathrel{\pp}}
[x\cc y \mid y \in (xs \gufx{ce} (r{-}1))]
\end{IEEEeqnarraybox}
\end{leftdisplay}
\lipsum[1-5]
\end{document}
答案2
看看这是否接近所需的代码:
\documentclass[conference,a4paper]{IEEEtran}
%\usepackage{egreg}
\usepackage[T1]{fontenc}
\usepackage{adjustbox}
\usepackage{amssymb, amsthm}
\usepackage{nccmath, mathtools}
\usepackage{lipsum}
\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle #2}}}}
\newcommand{\gufx}[1] {\scalemath{1.1}{\text{\,\guilsinglleft{#1}\guilsinglright}}\,\,}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand{\cc}{\mathbin{\!::\!}}
\newcommand{\pp}{\mathrel{\,+\!\!\!+\,}}
\begin{document}
\lipsum[1]
\begin{fleqn}
\begin{alignat*}{3}
&\mathrlap{c:\;\mathbb{N} \rightarrow \mathbb{N} \to \mathbb{N}}\\
&0 & \gufx{c} & (r{+}1) &&= 0 \\
&n & \gufx{c} & 0 &&= 1 \\
&(n{+}1) & \gufx{c} & &&= n \gufx{c} \! r + n\gufx{c} \!(r{-}1)
\end{alignat*}
\end{fleqn}
\lipsum[2]
\end{document}
编辑:删除了方程编号。