尝试将 macOS 样式的终端放置在节点内:
\documentclass[a4paper,openany,14pt,oneside,]{extbook}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,breakable}
\tcbuselibrary{minted}
\definecolor{terminalColor}{RGB}{38,50,56}
\definecolor{Button1}{RGB}{254,94,86}
\definecolor{Button2}{RGB}{254,188,45}
\definecolor{Button3}{RGB}{38,202,59}
\tcbuselibrary{skins,breakable,breakable}
\tcbuselibrary{minted}
\begin{document}
\def\bottom#1#2{\hbox{\vbox to #1{\vfill\hbox{#2}}}}
\begin{tikzpicture}[remember picture, overlay]
\node[color=black,fill=yellow, scale=1.0,transform shape,anchor=north west,
minimum height=0.5\pageheight,
minimum width=1.0\pagewidth,] (foo) at (current page.north west) {\bottom{0.45\pageheight}{
\begin{tcblisting}{width=11cm,listing engine=minted,
minted style=native, minted language=bash,
enhanced,colback=white,colframe=gray,
listing only,title=\tikz{
\node[circle,fill=Button1,inner sep=3pt] (c) at (0,0){};
\node[circle,fill=Button2,inner sep=3pt] (c) at (0.5,0){};
\node[circle,fill=Button3,inner sep=3pt] (c) at (1,0){};
}
}
$ ls -lt
# lists folder contents in date order
\end{tcblisting}
}};
% \$ ls -lt
% \# lists folder contents in chronological order
\end{tikzpicture}
\end{document}
得到右边的输出,出现错误
Argument of \verbatim@ has an extra }
。如果我删除tcblisting
块并在节点内放入简单文本,它就可以编译。
如何将该tcblisting
块正确地放置在节点内?
注意:为了实现相同的页面布局,我尝试将其放在tcblisting
里面,minipage
但出现了相同(或类似)的错误。
答案1
只需删除已定义bottom
及其有问题的}
s 并将其放入text height=0.50\pageheight
(主布局设置)节点的选项中即可:
\documentclass[a4paper,openany,14pt,oneside,]{extbook}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,breakable}
\tcbuselibrary{minted}
\definecolor{terminalColor}{RGB}{38,50,56}
\definecolor{Button1}{RGB}{254,94,86}
\definecolor{Button2}{RGB}{254,188,45}
\definecolor{Button3}{RGB}{38,202,59}
\tcbuselibrary{skins,breakable,breakable}
\tcbuselibrary{minted}
\begin{document}
\begin{tikzpicture}[remember picture, overlay]
\node[color=black,fill=yellow, scale=1.0,anchor=north west,
minimum height=0.5\pageheight,
minimum width=1.0\pagewidth,text height=0.50\pageheight] (foo) at (current page.north west)
{\begin{tcblisting}{width=11cm,listing engine=minted,minted style=native,minted language=bash,enhanced,colback=white,colframe=gray,listing only,title=\tikz{
\draw node[circle,fill=Button1,inner sep=3pt,minimum size=0.2cm] (c) at (0,0) {};
\draw node[circle,fill=Button2,inner sep=3pt,minimum size=0.2cm] (c) at (0.5,0){};
\draw node[circle,fill=Button3,inner sep=3pt,minimum size=0.2cm] (c) at (1,0){};
}
}
$ ls -lt
# lists folder contents in date order
\end{tcblisting}
};
\end{tikzpicture}
\end{document}
它不能完美地工作,即 macOS 风格的终端不能完全位于节点底部轮廓的顶部,但考虑到目前的情况,它看起来还不错