Wie erstelle ich einen seitlichen Rand?

Wie erstelle ich einen seitlichen Rand?

hier ist ein MWE:

\tcbox[enhanced,frame hidden,borderline={0.5pt}{0pt}{red,dashed}]{ab}

Dies ist das Ergebnis:
Bildbeschreibung hier eingeben

Ich möchte, dass nur der linke Rand angezeigt wird. Ist das möglich?
Danke!

Antwort1

borderline westHierzu können Sie die Option nutzen :

\documentclass{article}
\usepackage{kantlipsum}         % for sample text
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\newtcbox{\mybox}[1][]{
   enhanced, frame hidden, borderline west = {0.5pt}{0pt}{red,dashed}, #1
}

% Variant using a `minipage`-style boxing technique (this allows
% multiple lines, \tcblower, etc.)
\newtcolorbox{myleftlinebox}[1][]{
   enhanced, frame hidden, borderline west = {0.5pt}{0pt}{red,dashed}, #1
}

\begin{document}

This is \mybox{the box} and what comes next.

\bigskip
This is \mybox[on line]{the same box but \texttt{on line}} and what comes
next.

\bigskip \noindent
Variant based on \verb|\newtcolorbox|:
\begin{myleftlinebox}
  \kant[1]
\end{myleftlinebox}

\end{document}

Bildschirmfoto

Beachten Sie, dass das vorherige Beispiel durch die Verwendung eines mit deklarierten Stils ausgeklammert werden kann \tcbset, zum Beispiel:

\documentclass{article}
\usepackage{kantlipsum}         % for sample text
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\tcbset{my left line/.style={
          enhanced, frame hidden, borderline west = {0.5pt}{0pt}{red,dashed}
}}

\newtcbox{\mybox}[1][]{my left line, #1}
\newtcolorbox{myleftlinebox}[1][]{my left line, #1}

\begin{document}

This is \mybox{the box} and what comes next.

\bigskip
This is \mybox[on line]{the same box but \texttt{on line}} and what comes
next.

\bigskip \noindent
Variant based on \verb|\newtcolorbox|:
\begin{myleftlinebox}
  \kant[1]
  \tcblower
  \kant[2]
\end{myleftlinebox}

\end{document}

Bildschirmfoto

verwandte Informationen