请参阅以下 MWE 以了解我的疑问。谢谢。
梅威瑟:
\documentclass[a4paper]{article}
\usepackage{tcolorbox}
\usepackage{geometry,tcolorbox}
\geometry{showframe}
\geometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
\tcbuselibrary{listings}
\parindent0pt
\begin{document}
Question 1:\\
Why does \verb|fontupper=\huge| not work?\\
How to enlarge the fontsize?
\begin{tcblisting}{fontupper=\huge,listing side text,righthand ratio=0.4,sidebyside gap=4mm,}
\rule{1in}{5pt} some text some text some text some text some text
\end{tcblisting}
Question 2:\\
Why is there an indent on the second line of leftside of the box?\\
And how to eliminate this indent?
\end{document}
答案1
这并不是说它fontupper=\huge
没有任何效果。如果你输入fontupper=\huge Hello
,那么“Hello”就会很大。发生的情况是,一旦列表开始,列表的样式选项就会接管并重置所有内容。
你应该读一下listings
软件包的文档;这就是这里最重要的事情,连同设置这些选项的listing style
环境listing options
。tcblisting
默认情况下,使用 tcblistings 库,您将获得。显然,该样式将和非零值listing style=tcblatex
放入,这就是您在第二行看到缩进的原因。breaklines=true
breakindent
您可以定义自己的列表样式并使用它。或者您可以只使用 来设置 listings 包的选项listing options=
。例如,使其变大并且没有缩进:
\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{tcolorbox}
\geometry{showframe}
\geometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
\tcbuselibrary{listings}
\parindent0pt
\begin{document}
Question 1:\\
Why does \verb|fontupper=\huge| not work?\\
How to enlarge the fontsize?
\begin{tcblisting}{listing side text,
listing options={breakindent=0pt,breaklines=true,basicstyle=\ttfamily\huge},
righthand ratio=0.4,sidebyside gap=4mm}
\rule{1in}{5pt} some text some text some text some text some text
\end{tcblisting}
Question 2:\\
Why is there an indent on the second line of leftside of the box?\\
And how to eliminate this indent?
\end{document}
虽然不怎么漂亮,但你明白我的意思。