tcolorbox 中破解代码的问题

tcolorbox 中破解代码的问题

我有一个代码扩展到多个页面,我想将其分成多个页面。我使用了breakable库,但它对创建的 PDF 没有影响,所有代码都出现在同一页中。有人能帮帮我吗?

以下是 MWE。

\documentclass[11pt,letterpaper]{article}

\usepackage[left=1.00in, right=1.00in, top=1.00in, bottom=1.00in]{geometry}

\usepackage{tcolorbox}
\tcbuselibrary{minted,skins,breakable}

\newtcblisting{bashcode}[1][]{
  listing engine=minted,
  colback=bg,
  colframe=black!70,
  listing only,
  minted style=colorful,
  minted language=bash,
  minted options={linenos=true,numbersep=3mm,texcl=true,#1},
  left=5mm,enhanced,
  overlay={\begin{tcbclipinterior}\fill[black!25] (frame.south west)
            rectangle ([xshift=5mm]frame.north west);\end{tcbclipinterior}}
}
\definecolor{bg}{rgb}{0.85,0.85,0.85}

\begin{document}

\begin{bashcode}[]
# Unzip the file to the created directory
$ unzip code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4.zip -d ~

$ mkdir ~/camino

# Since the directory name is long, I do the following
$ mv ~/code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4/ ~/code
$ cd ~/camino
$ ls -F
apps/     inverters/           Makefile*  numerics/    sphfunc/
bin/      ISCodes/             man/       optimizers/  test/
data/     Jama/                matlab/    PointSets/   tools/
doc/      license.pdf*         mesd/      README.txt*  tractography/
fitters/  license.txt*         misc/      SGE/         UpdatePolicy.txt*
imaging/  logging.properties*  models/    simulation/

$ make

# Unzip the file to the created directory
$ unzip code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4.zip -d ~

$ mkdir ~/camino

# Since the directory name is long, I do the following
$ mv ~/code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4/ ~/code
$ cd ~/camino
$ ls -F
apps/     inverters/           Makefile*  numerics/    sphfunc/
bin/      ISCodes/             man/       optimizers/  test/
data/     Jama/                matlab/    PointSets/   tools/
doc/      license.pdf*         mesd/      README.txt*  tractography/
fitters/  license.txt*         misc/      SGE/         UpdatePolicy.txt*
imaging/  logging.properties*  models/    simulation/

$ make

# Unzip the file to the created directory
$ unzip code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4.zip -d ~

$ mkdir ~/camino

# Since the directory name is long, I do the following
$ mv ~/code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4/ ~/code
$ cd ~/camino
$ ls -F
apps/     inverters/           Makefile*  numerics/    sphfunc/
bin/      ISCodes/             man/       optimizers/  test/
data/     Jama/                matlab/    PointSets/   tools/
doc/      license.pdf*         mesd/      README.txt*  tractography/
fitters/  license.txt*         misc/      SGE/         UpdatePolicy.txt*
imaging/  logging.properties*  models/    simulation/

$ make

# Unzip the file to the created directory
$ unzip code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4.zip -d ~

$ mkdir ~/camino

# Since the directory name is long, I do the following
$ mv ~/code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4/ ~/code
$ cd ~/camino
$ ls -F
apps/     inverters/           Makefile*  numerics/    sphfunc/
bin/      ISCodes/             man/       optimizers/  test/
data/     Jama/                matlab/    PointSets/   tools/
doc/      license.pdf*         mesd/      README.txt*  tractography/
fitters/  license.txt*         misc/      SGE/         UpdatePolicy.txt*
imaging/  logging.properties*  models/    simulation/

$ make
\end{bashcode}

\end{document}

答案1

仅加载库是不够的;您需要将选项传递breakable给框:

\documentclass[11pt,letterpaper]{article}

\usepackage[left=1.00in, right=1.00in, top=1.00in, bottom=1.00in]{geometry}

\usepackage{tcolorbox}
\tcbuselibrary{minted,skins,breakable}

\newtcblisting{bashcode}[1][]{
  breakable,
  listing engine=minted,
  colback=bg,
  colframe=black!70,
  listing only,
  minted style=colorful,
  minted language=bash,
  minted options={linenos=true,numbersep=3mm,texcl=true,#1},
  left=5mm,enhanced,
  overlay={\begin{tcbclipinterior}\fill[black!25] (frame.south west)
            rectangle ([xshift=5mm]frame.north west);\end{tcbclipinterior}}
}
\definecolor{bg}{rgb}{0.85,0.85,0.85}

\begin{document}

\begin{bashcode}[]
# Unzip the file to the created directory
$ unzip code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4.zip -d ~

$ mkdir ~/camino

# Since the directory name is long, I do the following
$ mv ~/code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4/ ~/code
$ cd ~/camino
$ ls -F
apps/     inverters/           Makefile*  numerics/    sphfunc/
bin/      ISCodes/             man/       optimizers/  test/
data/     Jama/                matlab/    PointSets/   tools/
doc/      license.pdf*         mesd/      README.txt*  tractography/
fitters/  license.txt*         misc/      SGE/         UpdatePolicy.txt*
imaging/  logging.properties*  models/    simulation/

$ make

# Unzip the file to the created directory
$ unzip code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4.zip -d ~

$ mkdir ~/camino

# Since the directory name is long, I do the following
$ mv ~/code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4/ ~/code
$ cd ~/camino
$ ls -F
apps/     inverters/           Makefile*  numerics/    sphfunc/
bin/      ISCodes/             man/       optimizers/  test/
data/     Jama/                matlab/    PointSets/   tools/
doc/      license.pdf*         mesd/      README.txt*  tractography/
fitters/  license.txt*         misc/      SGE/         UpdatePolicy.txt*
imaging/  logging.properties*  models/    simulation/

$ make

# Unzip the file to the created directory
$ unzip code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4.zip -d ~

$ mkdir ~/camino

# Since the directory name is long, I do the following
$ mv ~/code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4/ ~/code
$ cd ~/camino
$ ls -F
apps/     inverters/           Makefile*  numerics/    sphfunc/
bin/      ISCodes/             man/       optimizers/  test/
data/     Jama/                matlab/    PointSets/   tools/
doc/      license.pdf*         mesd/      README.txt*  tractography/
fitters/  license.txt*         misc/      SGE/         UpdatePolicy.txt*
imaging/  logging.properties*  models/    simulation/

$ make

# Unzip the file to the created directory
$ unzip code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4.zip -d ~

$ mkdir ~/camino

# Since the directory name is long, I do the following
$ mv ~/code-163f67cbf550560aa351b3d0a3bbbd7a22863cb4/ ~/code
$ cd ~/camino
$ ls -F
apps/     inverters/           Makefile*  numerics/    sphfunc/
bin/      ISCodes/             man/       optimizers/  test/
data/     Jama/                matlab/    PointSets/   tools/
doc/      license.pdf*         mesd/      README.txt*  tractography/
fitters/  license.txt*         misc/      SGE/         UpdatePolicy.txt*
imaging/  logging.properties*  models/    simulation/

$ make
\end{bashcode}

\end{document}

在此处输入图片描述

相关内容