8

As a continuation of TikZ word search diagram here is the problem I'm facing. I did what Explorer suggested and it worked fine except that my rounded rectangles look like sausages or like Hieroglyphic cartouches because at their narrow ends they have lines on the secondary axis:

enter image description here Here is the code:

\documentclass{article}
\usepackage[cmyk]{xcolor}
\definecolor{myPB}{cmyk}{0.85,0.75,0,0}
\definecolor{myLB}{cmyk}{0.1,0.06,0,0}
\usepackage{tikz}
\usetikzlibrary{matrix,backgrounds}
\newlength{\mydrawlinewidth}
\setlength{\mydrawlinewidth}{1pt}
\NewDocumentCommand{\markA}{ O{red} m m }{%
    \draw[rounded corners=6mm,opacity=.5, line width=2pt,myPB,fill=myLB] 
    ([xshift=5pt,yshift=-5pt]yannis-#2.north west) 
    rectangle 
    ([xshift=-5pt,yshift=5pt]yannis-#3.south east);
}
\NewDocumentCommand{\markB}{ O{red} m m }{%
    \draw[rounded corners=6mm,opacity=.5,line width=2pt,myPB,fill=myLB]
       ([yshift=2pt]yannis-#2.north) 
    -- ([xshift=2pt]yannis-#3.east)
    -- ([yshift=-2pt]yannis-#3.south)
    -- ([xshift=-2pt]yannis-#2.west)
    -- cycle;
}
\NewDocumentCommand{\markC}{ O{red} m m }{%
    \draw[rounded corners=6mm,opacity=.5,line width=2pt,myPB,fill=myLB]
       ([xshift=2pt]yannis-#2.east) 
    -- ([yshift=-2pt]yannis-#3.south)
    -- ([xshift=-2pt]yannis-#3.west)
    -- ([yshift=2pt]yannis-#2.north)
    -- cycle;
}
\begin{document}
\begin{tikzpicture}
        \matrix (yannis) [%
            matrix of nodes,%
            column sep=0mm,%
            row sep=0mm,
            nodes={
                % draw,
                rectangle,anchor=center,
                line width=0.5pt,
                inner sep=2pt,outer sep=0pt,
                %font=\bfseries\huge,
                minimum size=1.1cm,
                }
            ]
      {
         S & G & A & Q & Q & T & C & E & F & R & E & P & Y & W & R \\
         W & L & Q & E & L & B & A & R & A & P & M & O & C & E & L \\
         Y & I & T & S & X & E & L & I & Y & A & H & U & W & R & A \\
         B & K & E & E & Y & C & W & L & J & T & M & A & K & B & F \\
         J & E & R & I & O & R & T & M & K & E & R & L & Q & E & T \\
         P & N & P & L & S & B & R & W & H & D & U & U & E & H & E \\
         E & E & R & R & E & W & V & S & S & M & L & N & K & E & R \\
         H & S & E & E & H & T & A & P & H & Y & S & I & C & A & L \\
         S & S & T & D & S & H & E & U & Q & V & L & V & R & Z & I \\
         O & R & N & N & I & F & L & L & A & S & N & E & E & K & F \\
         M & T & I & U & N & L & G & E & P & H & U & R & A & S & E \\
         W & K & O & Q & U & P & U & H & A & M & G & S & T & M & I \\
         A & F & A & R & P & J & M & S & L & R & O & E & E & H & C \\
         B & X & H & C & A & I & H & S & A & M & S & C & D & F & G \\
         I & P & R & O & P & H & E & T & S & N & S & I & F & X & Q \\
      };
    \begin{scope}[on background layer]
       \markA{1-6}{1-12}
       \markA{1-14}{6-14}
       \markC{1-15}{7-9}
       \markA{2-2}{9-2}
       \markA{2-4}{2-13}
       \markA{3-3}{11-3}
       \markA{3-4}{11-4}
       \markA{3-6}{3-12}
       \markA{3-15}{11-15}
       \markC{4-11}{9-6}
       \markA{6-5}{13-5}
       \markA{6-12}{13-12}
       \markA{7-1}{11-1}
       \markB{7-5}{14-12}
       \markA{8-8}{8-15}
       \markA{8-13}{14-13}
       \markB{10-7}{15-12}
       \markB{11-2}{15-6}
       \markA{14-3}{14-10}
       \markA{15-2}{15-9}
    \end{scope}
\end{tikzpicture}
\end{document}

How can I fix this?

@mickep I replaced the snippets by a complete minimal example.

2
  • 2
    Does it help to make the radius of the rounded corners smaller? (Also, please provide a complete minimal example instead of snippets) Commented yesterday
  • 1
    Yep, rounded corners must be less than half the height of the rectangle Commented yesterday

1 Answer 1

12

Rounded corners should be less than half the height of the rectangle/shape:

\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,calc}
\begin{document}
\begin{tikzpicture}[]
    \draw [rounded corners=8mm] (0,4) rectangle ++(4,1);
    \draw [rounded corners=6mm] (0,2) rectangle ++(4,1);
    \draw [rounded corners=4mm] (0,0) rectangle ++(4,1);
\end{tikzpicture}
\end{document}

strange rounded rectangles

1
  • Stupid of me… Thank you so much! Commented yesterday

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.