When I create boxes with tcolorbox
, I get an unwanted indentation in two places: once directly before the heading and secondly in place of the first paragraph (all the following paragraphs have no indentation as wanted).
I wrap each colorbox into a note
environment and its parts into separate field
environments to be able to parse the .tex-file later and import it into Anki.
The code for the definition of the colorboxes/environments:
\usepackage[skins, most]{tcolorbox}
\usepackage{titlesec}
\usepackage{xifthen}
\tcbset{default/.style={
enhanced,
breakable,
arc=0pt,
outer arc=0pt,
frame hidden,
fontupper=\normalsize\bfseries\boldmath,
fontlower=\small,
coltext=mediumgray!50!black,
colback=mediumgray!20,
parbox=false,
segmentation hidden,
grow to left by=-0.5cm,
grow to right by=-0.5cm,
}
}
\tcbset{definition/.style={default,
coltext=grapefruit!50!black,
colback=grapefruit!25
}
}
\newcounter{notefield}
\newenvironment{note}[1][default]
{
\titleformat*{\section}{\small\bfseries}
\titleformat*{\subsection}{\small\bfseries}
\titleformat*{\subsubsection}{\small\bfseries}
\setcounter{notefield}{0}
\begin{tcolorbox}[#1]
}
{
\end{tcolorbox}
}
\newenvironment{field}{}{}
\BeforeBeginEnvironment{field}{
\stepcounter{notefield}
\ifnum\value{notefield}=2
\tcblower
\fi
}
The code to generate a box:
\begin{note}[definition]
\begin{field}
Def.: Körper
\end{field}
\begin{field}
Ein kommutativer unitärer Ring, der nicht der Nullring ist, ist ein Körper, wenn in ihm jedes von Null verschiedene Element ein Inverses bezüglich der Multiplikation besitzt.
\end{field}
\end{note}
I use the package parskip
(with the configuration parfill
) to suppress indentations and I assume that it may conflict with tcolorboxes.
document
environment.