tikz 내에서 노드/구조체의 형식을 지정하는 방법은 무엇입니까?

tikz 내에서 노드/구조체의 형식을 지정하는 방법은 무엇입니까?

나는 다음을 만들었습니다아이젠하워 정사각형(또는 행렬)이것에 영감을 받아환상적인 답변:

아이슨하워 광장

나는 훨씬 더 공간 효율적이기를 바랍니다. 더 작은 텍스트 크기/체크 상자, 더 얇은 테두리, 사각형 사이에 공간/여백/여백 없음, 사각형 내에 수평선 없음 등.
왼쪽의 텍스트는 최대값의 좋은 근사치입니다. 사이즈 체크리스트 항목 텍스트가 있어야 합니다.

그러나 광범위한 수정 후에도 다음 속성을 변경할 수 없습니다.

  1. 테두리
    • 테두리를 매우 얇게 만듭니다(1px이면 충분함).
  2. 체크리스트 항목/상자
    • 수평선 제거
    • \Box각 체크리스트 항목을 더 작게 확인하거나 텍스트로 확장하세요.
    • 항목을 수직으로 더 단단하게/더 가깝게 만드시겠습니까?
  3. label텍스트
    • 개별 사각형의 왼쪽/상단 가장자리에 중앙 정렬

아래는 내 문서입니다.

main.tex

\documentclass[english]{book}

\usepackage{amssymb, tikz}
\usetikzlibrary{shapes.multipart, positioning, fit, backgrounds}

...

% \eisenbox: for making each box of an Eisenhower square
\newcommand{\eisenbox}[6][] {
    \node [rectangle split,rectangle split parts={#6}, fill=white,
    text width=5.25cm,align=left,text=#2,draw,sharp corners,draw=#2,
    #1]
    (multi-#3)
    {\strut$\Box$\nodepart{two}\strut$\Box$\nodepart{three}\strut$\Box$\nodepart{four}\strut$\Box$
    \nodepart{five}\strut$\Box$\nodepart{six}\strut$\Box$\nodepart{seven}\strut$\Box$
    \nodepart{eight}\strut$\Box$\nodepart{nine}\strut$\Box$\nodepart{ten}\strut$\Box$};
    \node[left=1pt of multi-#3.south west,anchor=south west,rotate=90,text=black] 
    (label-#3) {#5};
    
    \begin{scope}[on background layer]
        \node[fit=(multi-#3),fill=#2,sharp corners,
        label={[text=#2,anchor=south west,font=\bfseries]above left:#4}] (fit-#3){};
    \end{scope}
}

% \eisensquare: creates a fancy Eisenhower square
\newcommand{\eisensquare}[1] {
    \eisenbox{black}{tl}{\footnotesize Urgent}{\footnotesize Important}{#1}
    \eisenbox[right=0.2cm of multi-tl]{black}{tr}{\footnotesize Not Urgent}{}{#1}
    \eisenbox[below=0.2cm of multi-tl]{black}{bl}{}{\footnotesize Not Important}{#1}
    \eisenbox[right=0.2cm of multi-bl]{black}{br}{}{}{#1}
}

...

\begin{document}
    \frontmatter

    \maketitle
    ...

    \mainmatter

    ...
    \subfile{./folder/subfile.tex}

    \backmatter

\end{document}

subfile.tex

\documentclass[../main.tex]{subfiles}

    \begin{document}

    ...
    
    \paragraph{Foo}\mbox{}\\    
        \begin{tikzpicture}[font=\sffamily]
            \eisensquare{7}
        \end{tikzpicture}
    
    ...

\end{document}

내가 뭘 잘못하고 있는지 잘 모르겠습니다. , 등을 내부 어디든 tikz배치할 때마다 오류를 무시/발생시킵니다 .widthline width\node [options]\eisenbox

나는 pgf/를 완전히 처음 접했습니다.tikz 처음 접했기 때문에 통찰력을 얻으면 크게 감사하겠습니다.

편집 1 ------------

에 따라게르노의 모범적인 답변이제 막 얻었어요. 남은 것은 '사분면'당 다양한 항목 수에 대한 수정입니다. 나는 이것을 아주 오랫동안 매일 사용할 것이라는 사실이 아니었다면 일반적으로 그렇게 특별하지 않을 것입니다.

남은 줄 > 항목 수인 경우 빈 줄을 만드는 방법은 무엇입니까?

main.tex

\newcommand\eisenlabel[1]{{\footnotesize\sffamily#1}}

% arguments: 1st is total # lines, 2nd is # items
\newcommand{\eisenbox}[2]{\fbox{%
        \begin{tabular}{l}
            \multido{}{#1}{%
                \makebox[0.44\textwidth][l]{$\square$} %adding \\ here makes errors, but I believe its absence is FUBARing the table
            }
        \end{tabular}%
}}

% first argument: max lines, then items per quadrant starting with urgent+important
% could do this without 1st arg by determining largest value
% but not familiar enough with this so we'll just supply it manually (for now)
\newcommand{\eisensquare}[5] {%
    \fboxrule=0.1ex% <<< adjust line width
    \begin{tabular}{@{}r@{\hspace{0.3em}}c@{\hspace{-\fboxrule}}c@{}} % <<< adjust distance between rotated labels and box
        & \eisenlabel{urgent} & \eisenlabel{not urgent} \\
        \turnbox{90}{\makebox[0pt]{\eisenlabel{important}}}
        & \eisenbox{#1}{#2} & \eisenbox{#1}{#3} \\[-\fboxrule] 
        \turnbox{90}{\makebox[0pt]{\eisenlabel{not important}}}
        & \eisenbox{#1}{#4} & \eisenbox{#1}{#5}
    \end{tabular}%
}

subfile.tex

\(\eisensquare{5}{3}{4}{5}{3}\)

답변1

여기에 유연한 솔루션이 있습니다. \multido에서는 잘 작동하지 않아서 더욱 tabular기본적인 명령어를 사용했습니다. 최상위 명령은 다음과 같습니다.

\eisensquare{height of single box}{width of single box}{top left}{top right}{bottom left}{bottom right}

heightwidth절대 치수이거나 \baselineskip(선 높이) 또는 와 같은 길이의 배수일 수 있습니다 \textwidth.

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage{amssymb,rotating,multido}
% \eisenlabel{width}{label}
\newcommand\eisenlabel[2]{\makebox[#1]{\footnotesize\sffamily#2}}
% \veisenlabel{height}{label}
\newcommand\veisenlabel[2]{\turnbox{90}{\eisenlabel{#1}{#2}}\ }
% \eisenbox{height}{width}{number of items}
\newcommand\eisenbox[3]{\fbox{%
  \vbox to #1{%
    \multido{}{#3}{\hbox to #2{$\square$\hfill}}%
    \vfill  
  }%
}}
% \eisensquare{height of single box}{width of single box}{top left}{top right}{bottom left}{bottom right}
\newcommand\eisensquare[6]{{%
  \fboxrule=0.1ex%
  \vbox{%
    \hbox{\ \eisenlabel{#2}{urgent}\ \eisenlabel{#2}{not urgent}}%
    \hbox{\veisenlabel{#1}{important}\eisenbox{#1}{#2}{#3}\hspace{-\fboxrule}\eisenbox{#1}{#2}{#4}}%
    \nointerlineskip
    \vspace{-\fboxrule}%
    \hbox{\veisenlabel{#1}{not important}\eisenbox{#1}{#2}{#5}\hspace{-\fboxrule}\eisenbox{#1}{#2}{#6}}%
}}}
\begin{document}
\noindent
\eisensquare{5\baselineskip}{0.4\textwidth}{3}{4}{5}{3}

\noindent
\eisensquare{2cm}{5cm}{3}{4}{5}{3}
\end{document}

답변2

Tikz는 훌륭한 패키지이지만 이렇게 단순한 디자인을 위해서는 표 형식을 사용하는 것이 좋습니다. 모양을 수정하는 위치가 더 명확해질 수 있습니다.

여기에 이미지 설명을 입력하세요

글꼴 크기에 따라 변경되므로 길이 단위로 em또는 를 사용하는 것이 좋습니다 . ex코드에는 상자의 너비, 선 너비, 세로 레이블의 거리를 조정할 위치를 표시했습니다.

\documentclass{article}
\usepackage{amssymb,rotating}
\newcommand\eisenlabel[1]{{\footnotesize\sffamily#1}}
\newcommand\eisenline{\makebox[0.44\textwidth][l]{$\square$}}% <<< adjust width of boxes
\newcommand\eisenbox{\fbox{%
  \begin{tabular}{l}
    \eisenline\\
    \eisenline\\
    \eisenline\\
    \eisenline\\
    \eisenline\\
    \eisenline\\
    \eisenline
  \end{tabular}%
}}
\newcommand\eisensquare{{%
  \fboxrule=0.1ex% <<< adjust line width
  \begin{tabular}{@{}r@{\hspace{0.3em}}c@{\hspace{-\fboxrule}}c@{}} % <<< adjust distance between rotated labels and box
    & \eisenlabel{urgent} & \eisenlabel{not urgent} \\
  \turnbox{90}{\makebox[0pt]{\eisenlabel{important}}}
    & \eisenbox & \eisenbox \\[-\fboxrule] 
  \turnbox{90}{\makebox[0pt]{\eisenlabel{not important}}}
    & \eisenbox & \eisenbox
  \end{tabular}%
}}
\begin{document}
\noindent
\eisensquare
\end{document}

관련 정보