将文本对齐到两行

将文本对齐到两行

我该如何重新创建以下内容?

在此处输入图片描述

我尝试过一些方法,包括

\documentclass[english 9pt]{extarticle}

\usepackage[letterpaper, margin=.1in]{geometry} %% Set up the margins
\usepackage[tiny]{titlesec} %% Smaller sections
\usepackage{minted} %% Syntax highlighting
\usepackage{multicol} %% Mulitple columns
\setlength{\columnsep}{1cm} %% Distance between columns

\begin{document}

\begin{multicols*}{2}

  \section*{\textit{sllgen}}

  \begin{description}

  \item[Scanning] is the process of dividing the sequence of
    characters into words, punctuation, etc\ldots These units are
    called \textit{lexical items, lexemes,} or most often
    \textit{tokens}.

  \item[Parsing] is the process of organizing the sequences of tokens
    into hierarchical syntactic structures such as expressions,
    statements and blocks. This is like organizing or diagramming a
    sentence into clauses.

  \end{description}

  \section*{Section 3.1 - Specification and Implementation Strategy}

  \paragraph{}
  Specifications will be as follows:\\

  (value-of $exp$ $p$) = $val$\\

  We will have the following rules:\\

  \begin{align}
    \textit{Program} ::= & \textit{Expression} \\
                         & \fbox{a-program (exp1)}
  \end{align}

  \paragraph{}
  The flow goes like this:

  \begin{minted}[linenos]{racket}
    (run "fun() = up(42)")
  \end{minted}

\end{multicols*}
\end{document}

但是,我没有得到预期的结果。

答案1

下面是一个用于tabbing获取水平对齐标记的示例:

在此处输入图片描述

\documentclass[9pt]{extarticle}

\usepackage[letterpaper, margin=.1in]{geometry} %% Set up the margins
\usepackage[tiny]{titlesec} %% Smaller sections
\usepackage{minted} %% Syntax highlighting
\usepackage{multicol} %% Mulitple columns
\setlength{\columnsep}{1cm} %% Distance between columns

\begin{document}

\begin{multicols*}{2}

  \section*{\textit{sllgen}}

  \begin{description}

  \item[Scanning] is the process of dividing the sequence of
    characters into words, punctuation, etc\ldots These units are
    called \textit{lexical items, lexemes,} or most often
    \textit{tokens}.

  \item[Parsing] is the process of organizing the sequences of tokens
    into hierarchical syntactic structures such as expressions,
    statements and blocks. This is like organizing or diagramming a
    sentence into clauses.

  \end{description}

  \section*{Section 3.1 - Specification and Implementation Strategy}

  Specifications will be as follows:

  \hspace{2em}$(\textrm{value-of $exp$ $p$}) = \textit{val}$

  We will have the following rules:

  \begin{tabbing}
    \textit{Expression} \= ::= \= \kill
    \textit{Program}    \> ::= \> \textit{Expression} \\
                        \>     \> \fbox{\ttfamily a-program (exp1)} \\
    \textit{Expression} \> ::= \> \textit{Identifier} \\
                        \>     \> \fbox{\ttfamily var-exp (var)}
  \end{tabbing}

  \paragraph{}
  The flow goes like this:

  \begin{minted}[linenos]{racket}
    (run "fun() = up(42)")
  \end{minted}

\end{multicols*}
\end{document}

还有许多其他选项(例如,使用tabular结构,甚至枚举/描述)。

相关内容