这是我的 MWE:
\documentclass[12pt]{article}
\usepackage[most]{tcolorbox}
\tcbset{sidebyside,
breaklines=true,
postbreak=\mbox{\textcolor{red{$\hookrightarrow$}\space}}}
\begin{document}
\begin{tcblisting}{
comment and listing,
comment style={scale=2},
pdf comment,
freeze pdf,
compilable listing,
run pdflatex,
}
\documentclass[border=10pt]{standalone}
\begin{document}
\(1 = =2 = 2= 22=123=3= 13=1 313= 1 31=3131=3\)
\end{document}
\end{tcblisting}
\end{document}
它产生:
问题:如何用小红箭头打破长线来实现这个效果?
答案1
两个问题:
breaklines
和postbreak
是 listings 包中的选项,而不是 tcolorbox 包中的选项。您不能直接在\tcbset{...}
语法错误
\textcolor{red{..}}
\documentclass[12pt]{article}
\usepackage[most]{tcolorbox}
\tcbset{
sidebyside,
listing options={
basicstyle=\small\ttfamily,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space}
}
}
\begin{document}
\begin{tcblisting}{
comment and listing,
comment style={scale=2},
pdf comment,
freeze pdf,
compilable listing,
run pdflatex,
}
\documentclass[border=10pt]{standalone}
\begin{document}
\(1 = =2 = 2= 22=123=3= 13=1 313= 1 31=3131=3\)
\end{document}
\end{tcblisting}
\end{document}