环境内的预期段落

环境内的预期段落

几年后,我决定重新回归美丽的 LaTeX 排版。我刚刚决定磨练我的 LaTeX 技能,但发现这并不容易。

这是我的问题:我从书籍类文件(World Scientific Publishing)中找到了此代码,它制作了一个编号的框。

但是此代码不允许我缩进第一段之后的段落(在下图中,第二段以“Let”开头,这是有意的。)我想知道如何像下图一样缩进第一段之后的段落。框式

代码如下:

\documentclass[12pt,a4paper]{book}
\usepackage{boxedminipage}

\newcounter{boxcnt}[chapter]
\renewcommand\theboxcnt{\thechapter.\arabic{boxcnt}}
\newenvironment{boxedtxt}[1]{%
  \vskip6pt
  \parindent0pt\leftskip0pt
  \itemindent0pt\leftmargin0pt
  \fboxsep=8pt
  \normalfont
  \refstepcounter{boxcnt}
  \begin{boxedminipage}[0.5pt]{\hsize}
    \selectfont
    {\bfseries{Box\ \theboxcnt\enspace}#1}
    \vskip 6pt plus2pt minus1pt
    \par\noindent\ignorespaces
}{%
  \end{boxedminipage}%
  \vskip6pt\noindent\ignorespacesafterend
}

\begin{document}

\begin{boxedtxt}{Summation and series}
Summation is the operation of addition. The result of summation is called the
sum. The summation operation can be conveniently indicated by the the summation
symbol (the capital sigma, $\sum$). For instance, the sum of the square of the
first four natural numbers can be written as
\[
  \sum_{k=1}^{4}{k^2}= 1 + 2^2+3^2 +4^2 = 30,
\]
where $k=1$ in the subscript and 4 in the superscript denote that the summation
index $k$ takes integer values from 1 to 4.

Let $\{a_k\}_{k=1}^{n} = {a_1+a_2+\cdots.+a_n}$ be a sequence of n numbers bla
bla \ldots 
\end{boxedtxt} 
It is noted that the matrix bla bla \ldots 
\end{document}

答案1

我已经修正了代码,以便它能满足您的要求。但是,我还提出了另一个类似的环境,我称之为 fboxedtxt基于framed包的环境,它的优点是可以在必要时跨页中断。此外,如果需要,修改代码以获得彩色框架和/或阴影环境并不太困难。

\documentclass[12pt,a4paper]{book}
\usepackage{fourier, erewhon}
\usepackage[showframe]{geometry}
\usepackage[x11names]{xcolor}
\usepackage{boxedminipage}
\usepackage{framed}
\usepackage{amsmath}

\newcounter{boxcnt}[chapter]
\renewcommand\theboxcnt{\thechapter.\arabic{boxcnt}}
\newenvironment{boxedtxt}[1]
       {\vskip6pt
\leftskip0pt
\itemindent0pt\leftmargin0pt
\fboxsep=8pt
\normalfont
\refstepcounter{boxcnt}\noindent
\begin{boxedminipage}[0.5pt]{\hsize}\selectfont{\bfseries{Box\
    \theboxcnt\enspace}#1}\vskip 6pt plus2pt minus1pt
    \par\noindent\ignorespaces\parindent1em}
     {\end{boxedminipage}%
\vskip6pt \noindent\ignorespacesafterend}

\newcounter{fboxcnt}[chapter]
\renewcommand\thefboxcnt{\thechapter.\arabic{fboxcnt}}
\newenvironment{fboxedtxt}[1]
       {
\FrameSep=8pt
\OuterFrameSep=6pt
\FrameRule=1pt
\normalfont
\refstepcounter{fboxcnt}\noindent
\begin{oframed}\noindent\selectfont{\bfseries{Box\
    \theboxcnt\enspace}#1}\vskip 6pt plus2pt minus1pt
    \par\noindent\ignorespaces}
     {\end{oframed}%
\vskip6pt \noindent\ignorespacesafterend}
\begin{document}
Some text. Sometext. Some text. Sometext. Some text. Sometext. Some text. Sometext.
\setcounter{chapter}{3}\setcounter{boxcnt}{1}
\begin{boxedtxt}{Summation and series}
  Summation is the operation of addition. The result of summation is called the
  sum. The summation operation can be conveniently indicated by the the summation
  symbol (the capital sigma, $\sum$). For instance, the sum of the square of the
  first four natural numbers can be written as
  \[ \sum_{k=1}^{4}{k^2}= 1 + 2^2+3^2 +4^2 = 30, \]
  where $k=1$ in the subscript and 4 in the superscript denote that the summation
  index $k$ takes integer values from 1 to 4.

  Let $\{a_k\}_{k=1}^{n} = \bigl\{a_1,a_2,\dots, a_n\bigr\}$ be a sequence of $ n $ numbers in which each term $a_k$ is given by a certain rule, whose character is here irrelevant. A series is the sum of a sequence and can be written in summation notation as
  \[ \sum_{k = 1}^{n} = a_1 + a_2 + \dotsm + a_n\]%
  If the number of terms is finite, the series is called a finite series; otherwise it is called an infinite series. An example of an infinite series is the geometric series
  \[ \sum_{k = 0}^{\infty}\frac{1}{2^k} = 1 + \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} + \dotsm \]%
\end{boxedtxt}
It is noted that the matrix bla bla \ldots
\setcounter{boxcnt}{1}
\begin{fboxedtxt}{Summation and series}
  Summation is the operation of addition. The result of summation is called the
  sum. The summation operation can be conveniently indicated by the the summation
  symbol (the capital sigma, $\sum$). For instance, the sum of the square of the
  first four natural numbers can be written as
  \[ \sum_{k=1}^{4}{k^2}= 1 + 2^2+3^2 +4^2 = 30, \]
  where $k=1$ in the subscript and 4 in the superscript denote that the summation
  index $k$ takes integer values from 1 to 4.

  Let $\{a_k\}_{k=1}^{n} = \bigl\{a_1,a_2,\dots, a_n\bigr\}$ be a sequence of $ n $ numbers in which each term $a_k$ is given by a certain rule, whose character is here irrelevant. A series is the sum of a sequence and can be written in summation notation as
  \[ \sum_{k = 1}^{n} = a_1 + a_2 + \dotsm + a_n\]%
  If the number of terms is finite, the series is called a finite series; otherwise it is called an infinite series. An example of an infinite series is the geometric series
  \[ \sum_{k = 0}^{\infty}\frac{1}{2^k} = 1 + \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} + \dotsm \]%
\end{fboxedtxt}

\end{document}

在此处输入图片描述

在此处输入图片描述

相关内容