对齐:枚举中的 tcolorbox

对齐:枚举中的 tcolorbox

我怎样才能将枚举的项目符号与 tcolorbox 的顶部对齐?

在此处输入图片描述

平均能量损失

\documentclass[parskip=full]{scrartcl}

\usepackage{lipsum}

\usepackage{tikz}
\usepackage[most]{tcolorbox}

\begin{document}

\lipsum[1]

\begin{itemize}
\item Lorem ipsum
\item
  \begin{tikzpicture}[scale=(\linewidth-\baselineskip)/20cm,baseline={([yshift=-1em] current bounding box.north)}]
  \draw[step=1,help lines,black!20] (-0.95,-0.95) grid (8.95,8.95);
  \draw[thick,->] (-1,0) -- (9,0) node[pos=0.97,below] {$x$};
  \draw[thick,->] (0,-1) -- (0,9) node[pos=0.97,left] {$y$};
  \foreach \x/\xtext in {1,2,...,8}
      \draw[shift={(\x,0)}] (0pt,4pt) -- (0pt,-4pt) node[below] {$\xtext$};
  \foreach \y/\ytext in {1,2,...,8}
      \draw[shift={(0,\y)}] (4pt,0pt) -- (-4pt,0pt) node[left] {$\ytext$};
  \node[below right] at (0,0) {0};
  \end{tikzpicture}
\item
  \tcbsidebyside[sidebyside adapt=left, blanker, sidebyside gap=1cm, 
                 sidebyside align=top seam]{%
  \begin{tikzpicture}[scale=\linewidth/20cm, baseline=(current bounding box.north)]
    \draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
    \draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
    \draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
  \end{tikzpicture}%
  }{Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.}
\end{itemize}

\end{document}

答案1

最初tcolorboxes 是底部对齐的,即box align=bottom设置的,但是这里,应该将其对齐到顶部,因此box align=top在 的选项中使用\tcbsidebyside

\documentclass[parskip=full]{scrartcl}

\usepackage{lipsum}

\usepackage{tikz}
\usepackage[most]{tcolorbox}

\begin{document}

\lipsum[1]

\begin{itemize}
\item Lorem ipsum
\item
  \begin{tikzpicture}[scale=(\linewidth-\baselineskip)/20cm,baseline={([yshift=-1em] current bounding box.north)}]
  \draw[step=1,help lines,black!20] (-0.95,-0.95) grid (8.95,8.95);
  \draw[thick,->] (-1,0) -- (9,0) node[pos=0.97,below] {$x$};
  \draw[thick,->] (0,-1) -- (0,9) node[pos=0.97,left] {$y$};
  \foreach \x/\xtext in {1,2,...,8}
      \draw[shift={(\x,0)}] (0pt,4pt) -- (0pt,-4pt) node[below] {$\xtext$};
  \foreach \y/\ytext in {1,2,...,8}
      \draw[shift={(0,\y)}] (4pt,0pt) -- (-4pt,0pt) node[left] {$\ytext$};
  \node[below right] at (0,0) {0};
  \end{tikzpicture}
\item
  \tcbsidebyside[box align=top,sidebyside adapt=left, blanker, sidebyside gap=1cm, 
                 sidebyside align=top seam]{%
  \begin{tikzpicture}[scale=\linewidth/20cm, baseline=(current bounding box.north)]
    \draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
    \draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
    \draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
  \end{tikzpicture}%
  }{Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.}
\end{itemize}

\end{document}

在此处输入图片描述

更新

\documentclass[parskip=full]{scrartcl}

\usepackage{lipsum}

\usepackage{tikz}
\usepackage[most]{tcolorbox}

\begin{document}

\lipsum[1]

\begin{itemize}
\item Lorem ipsum
\item
  \begin{tikzpicture}[scale=(\linewidth-\baselineskip)/20cm,baseline={([yshift=-1em] current bounding box.north)}]
  \draw[step=1,help lines,black!20] (-0.95,-0.95) grid (8.95,8.95);
  \draw[thick,->] (-1,0) -- (9,0) node[pos=0.97,below] {$x$};
  \draw[thick,->] (0,-1) -- (0,9) node[pos=0.97,left] {$y$};
  \foreach \x/\xtext in {1,2,...,8}
      \draw[shift={(\x,0)}] (0pt,4pt) -- (0pt,-4pt) node[below] {$\xtext$};
  \foreach \y/\ytext in {1,2,...,8}
      \draw[shift={(0,\y)}] (4pt,0pt) -- (-4pt,0pt) node[left] {$\ytext$};
  \node[below right] at (0,0) {0};
  \end{tikzpicture}
\item
  \makeatletter
  \tcbsidebyside[baseline={\tcb@height-2\kvtcb@boxsep+\baselineskip-2\lineskip}, sidebyside adapt=left, blanker, sidebyside gap=1cm, 
                 sidebyside align=top seam]{%
  \begin{tikzpicture}[scale=\linewidth/20cm, baseline=(current bounding box.north)]
    \draw[step=1,help lines,black!20] (-4.95,-3.45) grid (4.95,3.45);
    \draw[thick] (-2.5,0) ellipse [x radius=2.25, y radius=3.4];
    \draw[thick] (2.5,0) ellipse [x radius=2.25, y radius=3.4];
  \end{tikzpicture}%
  }{Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 
  Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.}
\makeatother
\end{itemize}

\end{document}

相关内容