2

Could someone tell me how to get proper indentation in my tcolorbox environment (created with newtcbtheorem)? I got from other questions that we can use before upper, but apparently when using newtcbtheorem and a plain style this is not helpful as before upper already contains the label, which is erased by the added code. I've seen in the doc that there are related options such as before upper app, but I don't see how to use that properly (and configure it only once for all the document).

MWE:

\documentclass{article}
\usepackage{polyglossia}
\usepackage[most,theorems,skins,listings]{tcolorbox}
\tcbset{
  proofstyleone/.style={
    theorem style=plain,
    coltitle=black,
  },
  proofstyletwo/.style={
    theorem style=plain,
    coltitle=black,
    before upper=\setlength{\parindent}{1em}\everypar{{\setbox0\lastbox}\everypar{}},
  }
}
\newtcbtheorem[]{tcbproofone}{Proof}{proofstyleone}{p}
\newtcbtheorem[]{tcbprooftwo}{Proof}{proofstyletwo}{p}

\begin{document}
\begin{tcbproofone*}{}
This is a paragraph to test.

There should be an indent here.
\end{tcbproofone*}

\begin{tcbprooftwo*}{}
This is a paragraph to test.

There should be an indent here.
\end{tcbprooftwo*}
\end{document}
5
  • Can you give a sketch about what indentation do you want? A 1em indentation before the first paragraph starting with "Proof: "? Aug 12, 2020 at 18:38
  • 1
    Try before upper app={\setlength{\parindent}{1em}}? Aug 12, 2020 at 18:56
  • @muzimuzhiZ I just noticed it does work on the MWE. But I tried that on my full document and I get ` Package pgfkeys Error: I do not know the key '/tcb/before upper app', to which you passed […]`. Not sure where the difference lies between the two documents.
    – Zooky
    Aug 12, 2020 at 21:14
  • 1
    before upper app is provided by library hooks of tcolorbox package. In your MWE, it is loaded by package option most. Aug 12, 2020 at 21:25
  • Right, I got it working, thank you. So before upper app was the correct option, but I misinterpreted the error message (I thought I just could not use this option with \newtcbtheorem, but of course if it was not loaded this explains everything).
    – Zooky
    Aug 13, 2020 at 7:14

1 Answer 1

3

From comments, with tcolorbox library hooks loaded, setting

before upper app={\setlength{\parindent}{1em}}

is sufficient.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .