在 tikz 节点中调整 itemize 环境中的文本

在 tikz 节点中调整 itemize 环境中的文本

我正在尝试对齐 tikz 节点中 itemize 环境中项目的文本。我也尝试使用参数,topsep但效果不如我所想。文本应位于每个文本框的文本框顶部,以便每个项目都位于同一基线上。也许有一个很好的解决方案可以将其对齐到 tikz 节点的顶部、中心或底部。

以下是代码

\documentclass[tikz, class=scrreprt, fontsize=10pt]{standalone}
\usepackage[T1]{fontenc}                                
\usepackage[lf, p, sflf, sfp]{libertine}
\usepackage{enumitem}

\usetikzlibrary{shapes, arrows.meta, positioning, calc, decorations.pathreplacing, calligraphy, intersections, backgrounds}
\tikzset{every picture/.style={/utils/exec={\sffamily\normalsize}}}

\definecolor{orange}{RGB}{252,141,89}           % orange
\definecolor{yellow}{RGB}{253,204,138}          % gelb
\definecolor{light}{RGB}{254,240,217}           % hellgelb

\tikzstyle{framebox}     = [rectangle, minimum width = 20cm, minimum height = 1cm, draw = black, fill = orange]
\tikzstyle{renderbox}    = [rectangle, minimum width = 4cm, minimum height = 2cm, draw = black]
\tikzstyle{textbox}      = [rectangle, minimum width = 4cm, minimum height = 2cm, draw = black, fill = light, text width = 3.8cm]
\tikzstyle{titlebox}     = [rectangle, minimum height = 1cm]
\tikzstyle{subtitlebox}  = [rectangle, minimum width = 4cm, minimum height = 0.5cm, draw = black, fill = yellow]

\setlist[itemize]{itemsep = -0.3em, topsep = 0em, wide = 0.1em, labelwidth = 0em, label = \small{$\bullet$}}

\begin{document}
    \begin{tikzpicture}[node distance = 0cm and 3cm, outer sep = 0, inner sep = 0cm, rounded corners = 1pt, line width = 1pt, align = center] 
        
        \node [framebox, minimum width = 14cm, minimum height = 5cm] (subjektivbox) {};
        
        \node [titlebox, below = 0cm of subjektivbox.north, minimum width = 14cm] (subjektivtitel) {\raisebox{-9pt}{\textbf{subjektive Messverfahren}}};
        
        \node [renderbox, below right = 0cm and 0.5cm of subjektivtitel.south west] (renderbox1) {};
        \node [renderbox, below = 0cm of subjektivtitel.south]                      (renderbox2) {};
        \node [renderbox, below left = 0cm and 0.5cm of subjektivtitel.south east]  (renderbox3) {};
        
        \node [subtitlebox, below = 0cm of renderbox1.north] (merkmal)  {\textbf{merkmalsorientiert}};
        \node [subtitlebox, below = 0cm of renderbox2.north] (ereignis) {\raisebox{-9pt}{\textbf{ereignisorientiert}}};
        \node [subtitlebox, below = 0cm of renderbox3.north] (problem)  {\raisebox{-9pt}{\textbf{problemorientiert}}};
        
        \node [textbox, below = 0cm of merkmal] () {
            \begin{itemize}
                \item Kundenbefragungen
                \item Multiattribut
                \item Dekompositionell
        \end{itemize}};
        
        \node [textbox, below = 0cm of ereignis] () {
            \begin{itemize}
                \item Sequenzielle Ereignisse
                \item Critical Incidents
        \end{itemize}};
        
        \node [textbox, below = 0cm of problem] () {
            \begin{itemize}
                \item Problem Detecting
                \item Frequenz-Relevanz
        \end{itemize}};
        
    \end{tikzpicture}
\end{document}

答案1

您可以使用text depth将文本对齐到顶部。我添加了text depth=1.9cm样式textbox

在此处输入图片描述

\documentclass[tikz, class=scrreprt, fontsize=10pt]{standalone}
\usepackage[T1]{fontenc}                                
\usepackage[lf, p, sflf, sfp]{libertine}
\usepackage{enumitem}

\usetikzlibrary{shapes, arrows.meta, positioning, calc, decorations.pathreplacing, calligraphy, intersections, backgrounds}
\tikzset{every picture/.style={/utils/exec={\sffamily\normalsize}}}

\definecolor{orange}{RGB}{252,141,89}           % orange
\definecolor{yellow}{RGB}{253,204,138}          % gelb
\definecolor{light}{RGB}{254,240,217}           % hellgelb

\tikzstyle{framebox}     = [rectangle, minimum width = 20cm, minimum height = 1cm, draw = black, fill = orange]
\tikzstyle{renderbox}    = [rectangle, minimum width = 4cm, minimum height = 2cm, draw = black]
\tikzstyle{textbox}      = [rectangle, minimum width = 4cm, minimum height = 2cm, draw = black, fill = light, text width = 3.8cm,text depth=1.9cm]
\tikzstyle{titlebox}     = [rectangle, minimum height = 1cm]
\tikzstyle{subtitlebox}  = [rectangle, minimum width = 4cm, minimum height = 0.5cm, draw = black, fill = yellow]

\setlist[itemize]{itemsep = -0.3em, topsep = 0em, wide = 0.1em, labelwidth = 0em, label = \small{$\bullet$}}

\begin{document}
    \begin{tikzpicture}[node distance = 0cm and 3cm, outer sep = 0, inner sep = 0cm, rounded corners = 1pt, line width = 1pt, align = center] 
        
        \node [framebox, minimum width = 14cm, minimum height = 5cm] (subjektivbox) {};
        
        \node [titlebox, below = 0cm of subjektivbox.north, minimum width = 14cm] (subjektivtitel) {\raisebox{-9pt}{\textbf{subjektive Messverfahren}}};
        
        \node [renderbox, below right = 0cm and 0.5cm of subjektivtitel.south west] (renderbox1) {};
        \node [renderbox, below = 0cm of subjektivtitel.south]                      (renderbox2) {};
        \node [renderbox, below left = 0cm and 0.5cm of subjektivtitel.south east]  (renderbox3) {};
        
        \node [subtitlebox, below = 0cm of renderbox1.north] (merkmal)  {\textbf{merkmalsorientiert}};
        \node [subtitlebox, below = 0cm of renderbox2.north] (ereignis) {\raisebox{-9pt}{\textbf{ereignisorientiert}}};
        \node [subtitlebox, below = 0cm of renderbox3.north] (problem)  {\raisebox{-9pt}{\textbf{problemorientiert}}};
        
        \node [textbox, below = 0cm of merkmal] () {
            \begin{itemize}
                \item Kundenbefragungen
                \item Multiattribut
                \item Dekompositionell
        \end{itemize}};
        
        \node [textbox, below = 0cm of ereignis] () {
            \begin{itemize}
                \item Sequenzielle Ereignisse
                \item Critical Incidents
        \end{itemize}};
        
        \node [textbox, below = 0cm of problem] () {
            \begin{itemize}
                \item Problem Detecting
                \item Frequenz-Relevanz
        \end{itemize}};
        
    \end{tikzpicture}
\end{document}

答案2

如果你关心的只是如何绘制 boxbox,那么tcolorboxpure 包提供了更简单、更短的代码tikz,它也可以用于tikzpicture

\documentclass[border=3.141592, class=scrreprt]{standalone}
\usepackage[T1]{fontenc}
\usepackage[lf, p, sflf, sfp]{libertine}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{tcolorbox}{%
\setlist[itemize]{nosep,
                 leftmargin=*,
                 label=\textbullet,
                 before=\begin{minipage}[t]{\linewidth}, % <---
                 after=\end{minipage}}                   % <---
                            }

\usepackage[most]{tcolorbox}
\tcbuselibrary{raster}
\newtcolorbox{OuterBox}{colback=orange!80, colframe=black,
                        sharp corners,
                        halign=center,  
                        }

\begin{document}
\begin{OuterBox}
    \textbf{Subjektive Messverfahren}\par\medskip%
\begin{tcbitemize}[%
        raster columns=3,
        raster equal height,
        before=,    after=\hfill,
        left=0pt,right=0mm,top=1mm,bottom=1mm,
        sharp corners,
        colframe=black, colback=yellow!30, colbacktitle=orange!40, 
        coltitle=black, fonttitle=\bfseries, center title, 
        after title=\vphantom{bg},
        halign=left]
\tcbitem[title=merkmalsorientiert]
    \begin{itemize}
\item Kundenbefragungen
\item Multiattribut
\item Dekompositionell
    \end{itemize}
%
\tcbitem[title=ereignisorientiert]
    \begin{itemize}
\item Sequenzielle Ereignisse
\item Critical Incidents
   \end{itemize}
%
\tcbitem[title=problemorientiert]
    \begin{itemize}
\item Problem Detecting
\item Frequenz-Relevanz
    \end{itemize}
    \end{tcbitemize}   
\end{OuterBox}
\end{document}

在此处输入图片描述

注意,tcolorbox可以按如下方式插入tikz节点:

\node [inner sep=0pt] at (<coordinate>) 
            {\begin{OuterBox}
                    % box code as above
             \end{OuterBox}
             };

如果需要,您还可以为所有框命名。为此,您只需添加到 OuterBox 定义enhanced, remember as=#1,并添加到tcbitemize增强、覆盖和更改\tcbitem[title<0...]\tcbitem[title=..., remeber as=<name>]

相关内容