如何在拇指索引字典中绘制半圆?

如何在拇指索引字典中绘制半圆?

如何在拇指索引字典中绘制半圆?我正在使用以下代码字段工作并绘制一个矩形框:

\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}

但是当我更改以下代码来绘制但是当我更改以下代码来在拇指索引中绘制半圆时:

\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}

出现错误:

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

以及类似的错误。

我想知道正确的方法是什么?

答案1

left=0.3cm of x命令中有一个选项\nodex没有命名节点等,因此它必定会失败。

另外,我认为半圆应该按180度数旋转(或水平翻转)

字母尺寸太小,但 dict - 字母仍然存在。我会尝试重新处理这个问题。

\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}

在此处输入图片描述

相关内容