在以下示例中,我想leftright skip
自动计算/设置的值。该怎么做?
\documentclass{article}
\usepackage{tcolorbox}
\begin{document}
\begin{tcolorbox}[width=0.6\textwidth]
when the value of "left skip" is not given explictly, I want to set the value of "leftright skip" to (\textwidth - width)/2 automatically(implictly). What shall I do?
\end{tcolorbox}
\end{document}
答案1
您可以为 定义一个宏width
,并将\dimexpr
该宏用于leftrightskip
。如下所示:
\documentclass{article}
\usepackage{showframe}
\usepackage{tcolorbox}
\newlength{\tcbwd}
\setlength{\tcbwd}{0.6\linewidth}
\begin{document}
\begin{tcolorbox}[leftright skip=\dimexpr(\linewidth-\tcbwd)/2,width=\tcbwd]
when the value of "left skip" is not given explictly, I want to set the value of "leftright skip" to ($\backslash$textwidth - width)/2 automatically(implictly). What shall I do?
\end{tcolorbox}
\end{document}