平行包,边框

平行包,边框

我有这样的序言和代码。

    \documentclass[a4paper,14pt ]{report}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\usepackage{amssymb,amsfonts,amsmath,mathtext,cite,enumerate,float}
\usepackage{graphicx}
\usepackage[14pt]{extsizes}
\usepackage{times}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage[labelsep=period]{caption}
\usepackage{parallel,enumitem}
\DeclareCaptionLabelSeparator{par}{\par}
\captionsetup{labelsep=par,justification=centering}
\graphicspath{{images/}}


\newcommand\tablecaption[1]{
\captionsetup{labelsep=par,justification=centering}
\caption{#1}
}

\renewcommand{\baselinestretch}{1.5}\normalsize
\makeatletter
\renewcommand{\@biblabel}[1]{#1.}
\makeatother


\usepackage{geometry}
\geometry{left=3cm}
\geometry{right=1cm}
\geometry{top=2cm}
\geometry{bottom=2cm}

\renewcommand{\theenumi}{\arabic{enumi}}
\renewcommand{\labelenumi}{\arabic{enumi}}
\renewcommand{\theenumii}{.\arabic{enumii}}
\renewcommand{\labelenumii}{\arabic{enumi}.\arabic{enumii}.}
\renewcommand{\theenumiii}{.\arabic{enumiii}}
\renewcommand{\labelenumiii}{\arabic{enumi}.\arabic{enumii}.\arabic{enumiii}.}
\renewcommand{\rmdefault}{ftm}

     \begin{document}
\begin{Parallel}{0.40\textwidth}{0.65\textwidth}
\ParallelLText{\noindent
    \begin{enumerate}[itemsep=1ex]
      \item{Vertices are sorted in the following order 0,5,1,2,4,3}
      \item{Depth 1: \textbf{0},5,1,2,4,3} \\
      Depth 2: \textbf{1},2 \\
      Depth 3: \textbf{2} \\
      Depth 2: 1,\textbf{2}
      \item{Depth 1: 0,\textbf{5},1,2,4,3} \\
      Depth 2: \textbf{4},3 \\
      \item{Depth 1: 0,5,\textbf{1},2,4,3} \\
      Depth 2: \textbf{2},3,4 \\
      Depth 3: \textbf{3},4 \\
      Depth 4: \textbf{4} \\
      Depth 3: 3,\textbf{4} \\
      Depth 2: 2,3,\textbf{4} \\
      \item{Depth 1: 0,5,1,\textbf{2},4,3}
    \end{enumerate}
    }
\ParallelRText{\noindent
    \\\\ (the bold face node is expanded)
    \\\\
    Cannot expand, so $CBC$ is \{0,1,2\} with size 3 \\
    $d + (m - i)= 2 + (2 - 2) = 2 < 3,$ so we prune \\\\
    $2 + (2-1)=3 \le CBC$, so we prune
   \\\\ \\\\
    becomes our new $CBC$ with size 4 \\
    $3 + (2 - 2) = 3 < 4$, so we prune \\
    $2 + (3 - 2) = 3 < CBC$, so we prune \\\\
    $1 + (6 - 4) = 3 < CBC$, as depth = 1, we stop
}
\ParallelPar
\end{Parallel}
    \end{document} 

我已经编译了它并得到了很好的结果,但是当我将它添加到带有此类序言的文档中时,边框发生了变化。 在此处输入图片描述

我怎样才能做到如图所示:

在此处输入图片描述

答案1

当然,这取决于你的实际使用情况/文档布局,但我宁愿选择tabularx布局比使用parallel包裹。首先,代码是按行构建的,而不是按块分隔的左右块,从而提高了代码的可读性。

这是您的示例,为了简洁起见,已“最小化”:

在此处输入图片描述

\documentclass[a4paper]{report}
\usepackage{tabularx}% http://ctan.org/pkg/tabularx

\renewcommand{\baselinestretch}{1.5}\normalsize

\usepackage{geometry}% http://ctan.org/pkg/geometry
\geometry{left=3cm,right=1cm,top=2cm,bottom=2cm}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{rl@{\quad}X}
  1 & \multicolumn{2}{l}{Vertices are sorted in the following order 0,5,1,2,4,3} \\[\baselineskip]
  2 & Depth 1: \textbf{0},5,1,2,4,3 & (the bold face node is expanded) \\
    & Depth 2: \textbf{1},2 \\
    & Depth 3: \textbf{2} & Cannot expand, so $CBC$ is \{0,1,2\} with size 3 \\
    & Depth 2: 1,\textbf{2} & $d + (m - i)= 2 + (2 - 2) = 2 < 3,$ so we prune \\[\baselineskip]
  3 & Depth 1: 0,\textbf{5},1,2,4,3 \\
    & Depth 2: \textbf{4},3 & $2 + (2-1)=3 \le CBC$, so we prune \\[\baselineskip]
  4 & Depth 1: 0,5,\textbf{1},2,4,3 \\
    & Depth 2: \textbf{2},3,4 \\
    & Depth 3: \textbf{3},4 \\
    & Depth 4: \textbf{4} & becomes our new $CBC$ with size 4 \\
    & Depth 3: 3,\textbf{4} & $3 + (2 - 2) = 3 < 4$, so we prune \\
    & Depth 2: 2,3,\textbf{4} & $2 + (3 - 2) = 3 < CBC$, so we prune \\[\baselineskip]
  5 & Depth 1: 0,5,1,\textbf{2},4,3 & $1 + (6 - 4) = 3 < CBC$, as depth = 1, we stop
\end{tabularx}

\end{document}

“深度”与“描述”之间的差距是\quad

唯一的缺点是这个实现不会跨越页面边界。不过,我不确定这是否有必要。

答案2

一种方法是按照@Thorsten 的建议离开hyperref。但如果你想保留hyperref它,这会很有帮助。

\documentclass[a4paper,12pt ]{report}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\usepackage{amssymb,amsfonts,amsmath,mathtext,cite,enumerate,float}
\usepackage{graphicx}
\usepackage[14pt]{extsizes}
\usepackage{times}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage{setspace}
\usepackage[labelsep=period]{caption}
\usepackage{parallel}
\usepackage{enumitem}
\DeclareCaptionLabelSeparator{par}{\par}
\captionsetup{labelsep=par,justification=centering}
\graphicspath{{images/}}


\newcommand\tablecaption[1]{
\captionsetup{labelsep=par,justification=centering}
\caption{#1}
}

\onehalfspacing
% \renewcommand{\baselinestretch}{1.5}\normalsize
\makeatletter
\renewcommand{\@biblabel}[1]{#1.}
\makeatother


\usepackage{geometry}
\geometry{left=3cm}
\geometry{right=1cm}
\geometry{top=2cm}
\geometry{bottom=2cm}

\renewcommand{\theenumi}{\arabic{enumi}}
\renewcommand{\labelenumi}{\arabic{enumi}}
\renewcommand{\theenumii}{.\arabic{enumii}}
\renewcommand{\labelenumii}{\arabic{enumi}.\arabic{enumii}.}
\renewcommand{\theenumiii}{.\arabic{enumiii}}
\renewcommand{\labelenumiii}{\arabic{enumi}.\arabic{enumii}.\arabic{enumiii}.}
\renewcommand{\rmdefault}{ftm}

\begin{document}

    \begin{enumerate}[parsep=-10pt,itemsep=3ex,leftmargin=0.5cm]
      \item{Vertices are sorted in the following order 0,5,1,2,4,3}
    \end{enumerate}

\begin{Parallel}{0.35\textwidth}{0.63\textwidth}
\ParallelLText{\noindent
    \begin{enumerate}[resume*,parsep=0pt,itemsep=3ex,leftmargin=0.5cm,rightmargin=.65\textwidth]
      \item{Depth 1: \textbf{0},5,1,2,4,3} \\
      Depth 2: \textbf{1},2 \\
      Depth 3: \textbf{2} \\
      Depth 2: 1,\textbf{2}
        \end{enumerate}
      }
\ParallelRText{\noindent
\\\\(the bold face node is expanded)
    \\\\
    Cannot expand, so $CBC$ is \{0,1,2\} with size 3 \\
    $d + (m - i)= 2 + (2 - 2) = 2 < 3,$ so we prune

}
\ParallelPar
\ParallelLText{\noindent
\begin{enumerate}[resume*,parsep=0pt,itemsep=3ex,leftmargin=0.5cm,rightmargin=.65\textwidth]
      \item{Depth 1: 0,\textbf{5},1,2,4,3} \\
      Depth 2: \textbf{4},3 
          \end{enumerate}
      }
\ParallelRText{\noindent
 \\\\ \\$2 + (2-1)=3 \le CBC$, so we prune
}
\ParallelPar
\ParallelLText{\noindent
\begin{enumerate}[resume*,parsep=0pt,itemsep=3ex,leftmargin=0.5cm,rightmargin=.65\textwidth]
      \item{Depth 1: 0,5,\textbf{1},2,4,3} \\
      Depth 2: \textbf{2},3,4 \\
      Depth 3: \textbf{3},4 \\
      Depth 4: \textbf{4} \\
      Depth 3: 3,\textbf{4} \\
      Depth 2: 2,3,\textbf{4}
    \end{enumerate}
}
\ParallelRText{\noindent
  \\\\\\\\\\ becomes our new $CBC$ with size 4 \\
    $3 + (2 - 2) = 3 < 4$, so we prune \\
    $2 + (3 - 2) = 3 < CBC$, so we prune 

}
\ParallelPar
\ParallelLText{\noindent 
\begin{enumerate}[resume*,parsep=0pt,itemsep=3ex,leftmargin=0.5cm,rightmargin=.65\textwidth]
      \item{Depth 1: 0,5,1,\textbf{2},4,3}
    \end{enumerate}
    }
\ParallelRText{\noindent
 \\\\ $1 + (6 - 4) = 3 < CBC$, as depth = 1, we stop
}
\ParallelPar
\end{Parallel}

\end{document}

在此处输入图片描述

相关内容