Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

here's my MWE:

\documentclass[a5paper]{book} 
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc,calc}

\begin{document}

      \begin{tikzpicture}[overlay,remember picture]
      \node[
                fill=gray,
                inner sep=0pt,
                rounded rectangle,
                rounded rectangle west arc=none,
                rounded corners=15pt,
                text width=20mm,
        text height=20mm,
                align=center,
                anchor=north east] at
                    ($ (current page.north east) + (-14mm,-20mm) $){};
      \end{tikzpicture}

\end{document}

\end{document}

I'd like to make this shape look like the one at the bottom. How can I manage this?

enter image description here

share|improve this question
    
I think this is duplicate tex.stackexchange.com/questions/28115/… –  percusse Sep 2 at 10:05
    
@percusse I sure can't reproduce it using that solution. :D –  1010011010 Sep 2 at 10:15
    
Maybe rounded rectangle and rounded corners are incompatible –  Harald Sep 2 at 10:23
    
Moldevort, do you only need the shape? –  1010011010 Sep 2 at 10:23
    
I only need this shape. I don't want the kind of corners I get when I use "rounded rectangle" only. –  Moldevort Sep 2 at 10:25

3 Answers 3

up vote 5 down vote accepted

You can use \clip:

\documentclass[a5paper]{book}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc,calc}

\begin{document}

      \begin{tikzpicture}[overlay,remember picture]
      \clip ($ (current page.north east) + (-19mm,-20mm) $) rectangle ($ (current page.north east) + (-14mm,-20mm) + (-30mm,-20mm) $);
      \node[
                fill=gray,
                inner sep=0pt,
                rectangle,
                rounded corners=15pt,
                text width=30mm,
        text height=20mm,
                align=center,
                anchor=north east] at
                    ($ (current page.north east) + (-14mm,-20mm) $){};
      \end{tikzpicture}

\end{document}

enter image description here

If you want it at the paper edge, simply do this:

\documentclass[a5paper]{book}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc,calc}

\begin{document}

      \begin{tikzpicture}[overlay,remember picture]
      \node[
                fill=gray,
                inner sep=0pt,
                rounded rectangle,
                rounded rectangle west arc=none,
                rounded corners=15pt,
                text width=20mm,
        text height=20mm,
                align=center,
                anchor=north east] at
                    ($ (current page.north east) + (0mm,-20mm) $){};
      \end{tikzpicture}

\end{document}
share|improve this answer

It is reasonably straightforward to hack the rectangle shape to add four ifs to control whether the corner rounding is applied at each corner:

\documentclass[tikz,border=5]{standalone}
\newif\ifpgfshaperectangleroundnortheast
\newif\ifpgfshaperectangleroundnorthwest
\newif\ifpgfshaperectangleroundsoutheast
\newif\ifpgfshaperectangleroundsouthwest
\pgfkeys{/pgf/.cd,
  rectangle round north east/.is if=pgfshaperectangleroundnortheast,
  rectangle round north west/.is if=pgfshaperectangleroundnorthwest,
  rectangle round south east/.is if=pgfshaperectangleroundsoutheast,
  rectangle round south west/.is if=pgfshaperectangleroundsouthwest,
  rectangle round north east, rectangle round north west,
  rectangle round south east, rectangle round south west,
}
\makeatletter
\def\pgf@sh@bg@rectangle{%
  \pgfkeysgetvalue{/pgf/outer xsep}{\outerxsep}%
  \pgfkeysgetvalue{/pgf/outer ysep}{\outerysep}%
  \pgfpathmoveto{\pgfpointadd{\southwest}{\pgfpoint{\outerxsep}{\outerysep}}}%
  {\ifpgfshaperectangleroundnorthwest\else\pgfsetcornersarced{\pgfpointorigin}\fi%
    \pgfpathlineto{\pgfpointadd{\southwest\pgf@xa=\pgf@x\northeast\pgf@x=\pgf@xa}{\pgfpoint{\outerxsep}{-\outerysep}}}}%  
  {\ifpgfshaperectangleroundnortheast\else\pgfsetcornersarced{\pgfpointorigin}\fi%  
    \pgfpathlineto{\pgfpointadd{\northeast}{\pgfpoint{-\outerxsep}{-\outerysep}}}}%
  {\ifpgfshaperectangleroundsoutheast\else\pgfsetcornersarced{\pgfpointorigin}\fi%  
    \pgfpathlineto{\pgfpointadd{\southwest\pgf@ya=\pgf@y\northeast\pgf@y=\pgf@ya}{\pgfpoint{-\outerxsep}{\outerysep}}}}%
  {\ifpgfshaperectangleroundsouthwest\else\pgfsetcornersarced{\pgfpointorigin}\fi%  
    \pgfpathclose}}
\begin{document}
\begin{tikzpicture}[every node/.style={draw, rectangle, rounded corners=1ex}]
\node at (0,0) {A};
\node [rectangle round north east=false, rectangle round south east=false] at (1,0) {B};
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Is it weird that I like this solution more than the accepted answer? –  1010011010 Oct 13 at 10:23

A dirty solution if I ever saw one. But I guess it produces the desired effect.

http://i.imgur.com/EoCRn6L.png?1

\documentclass[a5paper]{book} 
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc,calc}

\begin{document}

\begin{tikzpicture}[overlay, remember picture]
\node[anchor=north east] at ($ (current page.north east) + (-14mm,-20mm) $){\begin{tikzpicture}
\draw[fill=gray,draw=none,
                rounded corners=15pt] (0,0)  -- (-3,0) -- (-3,-2)
[rounded corners=0pt] -- (0,-2) -- cycle;
\end{tikzpicture}};
\end{tikzpicture}

\end{document}

Specifically for thumbindices, you could use something like this:

\documentclass[a5paper]{book} 
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc,calc}

\begin{document}

\begin{tikzpicture}[overlay, remember picture,every node/.style={xshift=.05in,yshift=.05in,anchor=north east}]]
\foreach \i/\col in {0/gray,20/lightgray,40/orange,60/yellow} {
\node at ($ (current page.north east) + (0mm,{-\i mm}) $){
\begin{tikzpicture}
\draw[fill=\col,draw=none,
                inner sep=0pt,
                rounded corners=15pt, ] (0,0)  -- (-3,0) -- (-3,-2)
[rounded corners=0pt] -- (0,-2) -- cycle;
\end{tikzpicture}};
}
\end{tikzpicture}

\end{document}
share|improve this answer
    
Hm.. the aligning is not working properly. When I set (-14mm,-20mm) to (0mm,0mm) there's a little space above and right of it. How come? –  Moldevort Sep 2 at 11:01
    
@Moldevort Good question. I'm looking into it. The offset is -.05in in both x and y direction. Preliminary answer: I suspect this is caused by the fact that the enclosed tikzpicture in the node has white space around it. –  1010011010 Sep 2 at 11:11
    
I will use this shape for thumbindices so I need to align them very precisely. Is there any way to prevent this space? Elsewise I will have to substract 0.05in for each aligning –  Moldevort Sep 2 at 11:17
    
Check my updated answer. Remember that it's a huge workaround. –  1010011010 Sep 2 at 11:31
    
Try to avoid nesting tikzpictures: it is generally advisable. Instead, you can draw the shape via the pic operation available from TikZ version 3.0.0. –  Claudio Fiandrino Sep 2 at 11:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.