如何让 tcolorbox 环境中的段落首行缩进

发布于 2021-10-11 20:29:16

tcolorbox环境中的段落默认是不缩进的,如何设置才能使其中段落与正文有相同的缩进?

\documentclass{article}

\usepackage{tcolorbox}
\tcbset{
  sharp corners,
  boxrule=0pt,
  top=0mm,bottom=0pt,left=0pt,right=0pt,
  boxsep=0pt,
}

\begin{document}
I can swallow glass without hurting myself. I can swallow glass without hurting myself.

\begin{tcolorbox}
  This is a box: I can swallow glass without hurting myself. I can swallow glass without hurting myself. $\displaystyle\frac{d}{y}$ 

  This is a box: I can swallow glass without hurting myself. I can swallow glass without hurting myself. $\displaystyle\frac{d}{y}$ 
\end{tcolorbox}

I can swallow glass without hurting myself. I can swallow glass without hurting myself.

\end{document}

image.png

查看更多

关注者
0
被浏览
3.5k
:
2021-10-11
这家伙很懒,什么也没写!

我从(https://tex.stackexchange.com/questions/217974/indentation-inside-tcolorbox)看到类似的了,主要是parbox,我tcolorbox用的不多,是一个很蠢的方法解决的

\documentclass{article}

\usepackage{tcolorbox}
\tcbset{
  sharp corners,
  boxrule=0pt,
  top=0mm,bottom=0pt,left=0pt,right=0pt,
  boxsep=0pt,
  parbox=false
}

\begin{document}
I can swallow glass without hurting myself. I can swallow glass without hurting myself.

\begin{tcolorbox}
  % 空一行

  This is a box: I can swallow glass without hurting myself. I can swallow glass without hurting myself. $\displaystyle\frac{d}{y}$ 

  This is a box: I can swallow glass without hurting myself. I can swallow glass without hurting myself. $\displaystyle\frac{d}{y}$ 

  You can swallow glass without hurting yourself. New Bee.
\end{tcolorbox}

I can swallow glass without hurting myself. I can swallow glass without hurting myself.

\end{document}

结果如下
qishi.png

2 个回答
其实有点卡
其实有点卡 2021-10-11
这家伙很懒,什么也没写!

我找了好久也看到了一个方法,就是在tcolorbox环境外新“套壳”一层环境,然后在tcolorbox内部设置\parindent值。

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览