3

How draw semicircle in thumb index dictionary ? I am using the following code Field work and draw a rectangle Box:

\documentclass{book}
\usepackage{etoolbox}
\usepackage[paper=a4paper, top=1.5cm, headsep=0.4cm, bottom=1.5cm, left=1cm, right=1cm]{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{calc}

\usepackage{graphicx}
\usepackage{color}


% for some blindtext
\usepackage{lipsum}

\definecolor{goldenyellow}{rgb}{1.0, 0.87, 0.0}
\definecolor{golden}{rgb}{1.0, 0.84, 0.0}
% Thumb indexes' colors


\def\BoxColor#1{black!\the\numexpr103-#1-#1-#1\relax!blue}

\pagestyle{fancy}

% new counter to hold the current number of the letter to determine the vertical position
\newcounter{letternum}
% newcounter for the sum of all letters to get the right height of a box
\newcounter{lettersum}
\setcounter{lettersum}{33}
% some margin settings
\newlength{\thumbtopmargin}
\setlength{\thumbtopmargin}{1cm}
\newlength{\thumbbottommargin}
\setlength{\thumbbottommargin}{2.5cm}
% calculate the box height by dividing the page height
\newlength{\thumbheight}
\pgfmathsetlength{\thumbheight}{%
    (\paperheight-\thumbtopmargin-\thumbbottommargin)%
    /%
    \value{lettersum}
}
% box width
\newlength{\thumbwidth}
\setlength{\thumbwidth}{0.5cm}
% style the boxes
\tikzset{
    thumb/.style={
        text=golden,
        minimum height=\thumbheight,
        text width=\thumbwidth,
        outer sep=0pt,
        font=\sffamily\bfseries,
        }
}
\def\thumbnew{}
\def\thumbold{}
\usepackage{everypage}
\AddEverypageHook{\if\relax\thumbnew\relax\xdef\thumbnew{\thumbold}\fi}

\def\ethumbs#1,#2\relax{\if\relax#1\relax\else\eventhumb{#1}\fi%
    \if\relax#2\relax\else\ethumbs#2\relax\fi%
    \gdef\thumbnew{}%
    \gdef\thumbold{#2,}%
}
\def\othumbs#1,#2\relax{\if\relax#1\relax\else{#1}\fi%
    \if\relax#2\relax\else\othumbs#2\relax\fi%
    \gdef\thumbold{#1,}%
    \gdef\thumbnew{}%
}


\newcommand{\eventhumb}[1]{%
    % see pgfmanual.pdf for more information about this part
    \begin{tikzpicture}[remember picture, overlay]
    \node [thumb,fill=\BoxColor{#1}, text centered,anchor=north west,] at ($%
    (current page.north west)-%
    (0,\thumbtopmargin+#1*\thumbheight)%
    $) {\csname Let#1\endcsname};
    \end{tikzpicture}
}
% create a new command to set a new lettergroup with thumb indexes
\newcommand{\thumbindex}[1]{%
    % step the counter of the letters
    \refstepcounter{letternum}%
    \expandafter\gdef\csname Let\theletternum\endcsname{#1}%
    \xdef\thumbnew{\theletternum,\thumbnew}%

        \expandafter\ethumbs\thumbnew\relax}%


\newcommand*{\dictchar}[1]{
    \centerline{\parbox[c][3cm][c]{3cm}{%
            \centering
            \fontsize{24}{24}
            \selectfont
            {#1}}}
}

\fancypagestyle{dictstyle}{%
    \renewcommand{\headrulewidth}{0.4pt}
    \fancyhf{}
    \fancyhead[LE,LO]{{\fontfamily{phv}\selectfont{\textbf{\rightmark}}}}
    \fancyhead[CO,CE]{\thepage}%the page numbers will be printed when the dictionary is ready
    \fancyhead[RE,RO]{{\fontfamily{phv}\selectfont{\textbf{\leftmark}}}}}

% middle rule  
\setlength{\columnsep}{20pt}
\setlength{\columnseprule}{0.01pt}
\usepackage[xindy]{glossaries}

\makeglossaries

% The optional argument is in case you can't use the name as a label    
\newcommand{\dict}[4][]{%
    \newglossaryentry{#2}%
    {%
        name=#2,%
        symbol=#3,%
        description=#4,%
        #1%
    }%
}

\newglossarystyle{dict}%
{%
    \renewenvironment{theglossary}{}{\end{multicols}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{%
       \chapter*{\clearpage ##1}
      \thumbindex{\subsection*{##1}}

    \begin{multicols}{2}%
    }%
    \renewcommand*{\glsgroupskip}{\end{multicols}}%
\renewcommand{\glossaryentryfield}[5]{%
    \markboth{##2}{##2}%
    \par\vspace{0.25\baselineskip}%
    \textbf{\textsf{##2}} \textit{- ##4 -} ##3%
}%
}
\renewcommand*{\glossarysection}[2][]{}



 \begin{document}

\pagestyle{dictstyle}

 \dict{zero}{n}{\lipsum[4]}
 \dict{adhesive}{n}{\lipsum[5]}
 \dict{adhere}{n}{\lipsum[2]}
 \dict{adhesion}{n}{\lipsum[4]}
 \dict{adjacent}{n}{\lipsum[6]}
 \dict{adjust}{n}{\lipsum[6]}
 \dict{main}{n}{\lipsum[3]}
 \dict{material}{n}{\lipsum[1]}
 \dict{more}{n}{\lipsum[2]}
 \dict{zebra}{n}{\lipsum \lipsum \lipsum}
 \dict{adherence}{n}{\lipsum[3]}
 \dict{adjective}{n}{\lipsum[1]}
 \dict{adjoin}{n}{\lipsum[2]}
 \dict{mathematic}{n}{\lipsum[2]}
 \dict{adjourn}{n}{\lipsum[3]}
 \dict{adjournment}{n}{\lipsum[4]}
 \dict{adjunt}{n}{\lipsum[5]}
 \dict{adequate}{n}{\lipsum[1]}

\glsaddall
\printglossary[style=dict]
 \end{document}

But when I change the following code to draw But when I change the following code to draw semicircle in thumb index:

\documentclass{book}
\usepackage{etoolbox}
\usepackage[paper=a4paper, top=1.5cm, headsep=0.4cm, bottom=1.5cm, left=1cm, right=1cm]{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric,positioning}

\usepackage{graphicx}
\usepackage{color}

% for some blindtext
\usepackage{lipsum}

\definecolor{goldenyellow}{rgb}{1.0, 0.87, 0.0}
\definecolor{golden}{rgb}{1.0, 0.84, 0.0}
% Thumb indexes' colors


\def\BoxColor#1{black!\the\numexpr103-#1-#1-#1\relax!blue}

\pagestyle{fancy}

% new counter to hold the current number of the letter to determine the vertical position
\newcounter{letternum}
% newcounter for the sum of all letters to get the right height of a box
\newcounter{lettersum}
\setcounter{lettersum}{33}
% some margin settings
\newlength{\thumbtopmargin}
\setlength{\thumbtopmargin}{1cm}
\newlength{\thumbbottommargin}
\setlength{\thumbbottommargin}{2.5cm}
% calculate the box height by dividing the page height
\newlength{\thumbheight}
\pgfmathsetlength{\thumbheight}{%
    (\paperheight-\thumbtopmargin-\thumbbottommargin)%
    /%
    \value{lettersum}
}
% box width
\newlength{\thumbwidth}
\setlength{\thumbwidth}{0.5cm}
% style the boxes
\tikzset{
    thumb/.style={
        text=golden,
        minimum height=\thumbheight,
        text width=\thumbwidth,
        outer sep=0pt,
        font=\sffamily\bfseries,
        semicircle,
        }
}
\def\thumbnew{}
\def\thumbold{}
\usepackage{everypage}
\AddEverypageHook{\if\relax\thumbnew\relax\xdef\thumbnew{\thumbold}\fi}

\def\ethumbs#1,#2\relax{\if\relax#1\relax\else\eventhumb{#1}\fi%
    \if\relax#2\relax\else\ethumbs#2\relax\fi%
    \gdef\thumbnew{}%
    \gdef\thumbold{#2,}%
}
\def\othumbs#1,#2\relax{\if\relax#1\relax\else{#1}\fi%
    \if\relax#2\relax\else\othumbs#2\relax\fi%
    \gdef\thumbold{#1,}%
    \gdef\thumbnew{}%
}


\newcommand{\eventhumb}[1]{%
    % see pgfmanual.pdf for more information about this part
    \begin{tikzpicture}[remember picture, overlay]
    \node [thumb,fill=\BoxColor{#1}, text centered,left=0.3cm of x,shape border rotate=90] at ($%
    (current page.north west)-%
    (0,\thumbtopmargin+#1*\thumbheight)%
    $) {\csname Let#1\endcsname};
    \end{tikzpicture}
}
% create a new command to set a new lettergroup with thumb indexes
\newcommand{\thumbindex}[1]{%
    % step the counter of the letters
    \refstepcounter{letternum}%
    \expandafter\gdef\csname Let\theletternum\endcsname{#1}%
    \xdef\thumbnew{\theletternum,\thumbnew}%

        \expandafter\ethumbs\thumbnew\relax}%


\newcommand*{\dictchar}[1]{
    \centerline{\parbox[c][3cm][c]{3cm}{%
            \centering
            \fontsize{24}{24}
            \selectfont
            {#1}}}
}

\fancypagestyle{dictstyle}{%
    \renewcommand{\headrulewidth}{0.4pt}
    \fancyhf{}
    \fancyhead[LE,LO]{{\fontfamily{phv}\selectfont{\textbf{\rightmark}}}}
    \fancyhead[CO,CE]{\thepage}%the page numbers will be printed when the dictionary is ready
    \fancyhead[RE,RO]{{\fontfamily{phv}\selectfont{\textbf{\leftmark}}}}}

% middle rule  
\setlength{\columnsep}{20pt}
\setlength{\columnseprule}{0.01pt}
\usepackage[xindy]{glossaries}

\makeglossaries

% The optional argument is in case you can't use the name as a label    
\newcommand{\dict}[4][]{%
    \newglossaryentry{#2}%
    {%
        name=#2,%
        symbol=#3,%
        description=#4,%
        #1%
    }%
}

\newglossarystyle{dict}%
{%
    \renewenvironment{theglossary}{}{\end{multicols}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{%
       \chapter*{\clearpage ##1}
      \thumbindex{\subsection*{##1}}

    \begin{multicols}{2}%
    }%
    \renewcommand*{\glsgroupskip}{\end{multicols}}%
\renewcommand{\glossaryentryfield}[5]{%
    \markboth{##2}{##2}%
    \par\vspace{0.25\baselineskip}%
    \textbf{\textsf{##2}} \textit{- ##4 -} ##3%
}%
}
\renewcommand*{\glossarysection}[2][]{}



 \begin{document}

\pagestyle{dictstyle}

 \dict{zero}{n}{\lipsum[4]}
 \dict{adhesive}{n}{\lipsum[5]}
 \dict{adhere}{n}{\lipsum[2]}
 \dict{adhesion}{n}{\lipsum[4]}
 \dict{adjacent}{n}{\lipsum[6]}
 \dict{adjust}{n}{\lipsum[6]}
 \dict{main}{n}{\lipsum[3]}
 \dict{material}{n}{\lipsum[1]}
 \dict{more}{n}{\lipsum[2]}
 \dict{zebra}{n}{\lipsum \lipsum \lipsum}
 \dict{adherence}{n}{\lipsum[3]}
 \dict{adjective}{n}{\lipsum[1]}
 \dict{adjoin}{n}{\lipsum[2]}
 \dict{mathematic}{n}{\lipsum[2]}
 \dict{adjourn}{n}{\lipsum[3]}
 \dict{adjournment}{n}{\lipsum[4]}
 \dict{adjunt}{n}{\lipsum[5]}
 \dict{adequate}{n}{\lipsum[1]}

\glsaddall
\printglossary[style=dict]
 \end{document}

Appears error :

Package pgf Error: No shape named x is known. \glsgroupheading{A}

And similar errors.

I want to know what is the right way to do it?

1
  • There's a left=0.3cm of x option in your code. x is no named node, as far as I can see
    – user31729
    Jan 7, 2016 at 19:03

1 Answer 1

3

There's the left=0.3cm of x option in the \node command. x is no named node etc, as such, it must fail.

In addition, I think the semi-circle should be rotated by 180 degrees (or flipped horizontally)

The letter size is too small and the dict - letter is still there. I'll try to come back to this.

\documentclass{book}
%\usepackage{etoolbox}% not necessary in here
\usepackage[paper=a4paper, top=1.5cm, headsep=0.4cm, bottom=1.5cm, left=1cm, right=1cm]{geometry}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric,positioning}

\usepackage{graphicx}
\usepackage{color}

% for some blindtext
\usepackage{lipsum}

\definecolor{goldenyellow}{rgb}{1.0, 0.87, 0.0}
\definecolor{golden}{rgb}{1.0, 0.84, 0.0}
% Thumb indexes' colors


\def\BoxColor#1{black!\the\numexpr103-#1-#1-#1\relax!blue}

\pagestyle{fancy}

% new counter to hold the current number of the letter to determine the vertical position
\newcounter{letternum}
% newcounter for the sum of all letters to get the right height of a box
\newcounter{lettersum}
\setcounter{lettersum}{33}
% some margin settings
\newlength{\thumbtopmargin}
\setlength{\thumbtopmargin}{1cm}
\newlength{\thumbbottommargin}
\setlength{\thumbbottommargin}{2.5cm}
% calculate the box height by dividing the page height
\newlength{\thumbheight}
\pgfmathsetlength{\thumbheight}{%
    (\paperheight-\thumbtopmargin-\thumbbottommargin)%
    /%
    \value{lettersum}
}
% box width
\newlength{\thumbwidth}
\setlength{\thumbwidth}{0.5cm}
% style the boxes
\tikzset{
    thumb/.style={
        text=golden,
        minimum height=\thumbheight,
        text width=\thumbwidth,
        outer sep=0pt,
        font=\sffamily\bfseries,
        semicircle,
        }
}
\def\thumbnew{}
\def\thumbold{}
\usepackage{everypage}
\AddEverypageHook{\if\relax\thumbnew\relax\xdef\thumbnew{\thumbold}\fi}

\def\ethumbs#1,#2\relax{\if\relax#1\relax\else\eventhumb{#1}\fi%
    \if\relax#2\relax\else\ethumbs#2\relax\fi%
    \gdef\thumbnew{}%
    \gdef\thumbold{#2,}%
}
\def\othumbs#1,#2\relax{\if\relax#1\relax\else{#1}\fi%
    \if\relax#2\relax\else\othumbs#2\relax\fi%
    \gdef\thumbold{#1,}%
    \gdef\thumbnew{}%
}


\newcommand{\eventhumb}[1]{%
    % see pgfmanual.pdf for more information about this part
  \begin{tikzpicture}[remember picture, overlay]
    \node [thumb,fill=\BoxColor{#1}, text centered,left=-1cm,shape border rotate=-180] at ($%
    (current page.north west)-%
    (0,\thumbtopmargin+#1*\thumbheight)%
    $) {\csname Let#1\endcsname};
  \end{tikzpicture}
}
% create a new command to set a new lettergroup with thumb indexes
\newcommand{\thumbindex}[1]{%
    % step the counter of the letters
    \refstepcounter{letternum}%
    \expandafter\gdef\csname Let\theletternum\endcsname{#1}%
    \xdef\thumbnew{\theletternum,\thumbnew}%
    \expandafter\ethumbs\thumbnew\relax}%


\newcommand*{\dictchar}[1]{
    \centerline{\parbox[c][3cm][c]{3cm}{%
        \centering
        \fontsize{24}{24}
        \selectfont
        {#1}}}
}

\fancypagestyle{dictstyle}{%
    \renewcommand{\headrulewidth}{0.4pt}
    \fancyhf{}
    \fancyhead[LE,LO]{{\fontfamily{phv}\selectfont{\textbf{\rightmark}}}}
    \fancyhead[CO,CE]{\thepage}%the page numbers will be printed when the dictionary is ready
    \fancyhead[RE,RO]{{\fontfamily{phv}\selectfont{\textbf{\leftmark}}}}}

% middle rule  
\setlength{\columnsep}{20pt}
\setlength{\columnseprule}{0.01pt}
\usepackage[xindy]{glossaries}

\makeglossaries

% The optional argument is in case you can't use the name as a label    
\newcommand{\dict}[4][]{%
    \newglossaryentry{#2}%
    {%
        name=#2,%
        symbol=#3,%
        description=#4,%
        #1%
    }%
}

\newglossarystyle{dict}%
{%
  \renewenvironment{theglossary}{}{\end{multicols}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{%
  \chapter*{\clearpage ##1}
  \thumbindex{\subsection*{##1}}

  \begin{multicols}{2}%
  }%
  \renewcommand*{\glsgroupskip}{\end{multicols}}%
\renewcommand{\glossaryentryfield}[5]{%
  \markboth{##2}{##2}%
  \par\vspace{0.25\baselineskip}%
  \textbf{\textsf{##2}} \textit{- ##4 -} ##3%
}%
}
\renewcommand*{\glossarysection}[2][]{}



\begin{document}

\pagestyle{dictstyle}

 \dict{zero}{n}{\lipsum[4]}
 \dict{adhesive}{n}{\lipsum[5]}
 \dict{adhere}{n}{\lipsum[2]}
 \dict{adhesion}{n}{\lipsum[4]}
 \dict{adjacent}{n}{\lipsum[6]}
 \dict{adjust}{n}{\lipsum[6]}
 \dict{main}{n}{\lipsum[3]}
 \dict{material}{n}{\lipsum[1]}
 \dict{more}{n}{\lipsum[2]}
 \dict{zebra}{n}{\lipsum \lipsum \lipsum}
 \dict{adherence}{n}{\lipsum[3]}
 \dict{adjective}{n}{\lipsum[1]}
 \dict{adjoin}{n}{\lipsum[2]}
 \dict{mathematic}{n}{\lipsum[2]}
 \dict{adjourn}{n}{\lipsum[3]}
 \dict{adjournment}{n}{\lipsum[4]}
 \dict{adjunt}{n}{\lipsum[5]}
 \dict{adequate}{n}{\lipsum[1]}

 \glsaddall
 \printglossary[style=dict]
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .