我正在尝试在我正在书写的某个应用程序中,让带有一些文本的蓝色拇指索引一直向下移动到每一页的右侧。拇指索引上的文本可能在每一页上都不同。我无法让它正常工作。即使我尝试操纵它以在屏幕上获得“正确”显示,当我将其打印为硬拷贝时,它会变得很难看。
有谁知道我该如何更好地解决这个问题。任何帮助都将不胜感激!
我的代码:
\documentclass[a4paper,12pt,twoside]{article}
\usepackage[norsk]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{setspace}
\onehalfspacing
\usepackage{parskip}
\usepackage{fontawesome}
\usepackage{graphicx,tikz}
\definecolor{color1}{rgb}{0.22,0.45,0.70} %blå fra cvmodern.
\usepackage{lipsum}
\begin{document}
\setcounter{page}{0}
\pagenumbering{roman}
%Contact info:
\noindent
\begin{minipage}[t][0.8cm][b]{0.33\textwidth} \small{name} \\ \small{address} \\ \small{post number}
\end{minipage}
\begin{minipage}[t][0.8cm][b]{0.33\textwidth}\faMobilePhone \hspace{2.2mm} \small{666 66 666}\\ \faEnvelope \hspace{0.2mm} \small{[email protected]}
\end{minipage}
\begin{minipage}[t][0.8cm][b]{0.33\textwidth}\hfill \small{\today}
\end{minipage}
% thumb index:
\begin{tikzpicture}[overlay]
\tikzset{anchor=west} %used to rotate the textnodes.
\draw [color=color1, fill=color1] (17.5,-35) rectangle (18.5,10);
\node [rotate=90,white,font=\Large\bfseries,below left] at (17.6,2.2){Application};
\end{tikzpicture}
\vspace{0.3cm}
\textbf{Application on the job} \\
\lipsum
\begin{tikzpicture}[overlay]
\tikzset{anchor=west}
\draw [fill=color1,color=color1] (17.5,-35) rectangle (18.5,10);
\node [rotate=90,white,font=\Large\bfseries,below left] at (17.6,0.48){Appendix};
\end{tikzpicture}
\end{document}
答案1
您可以使用current page
节点系列来避免手动指定坐标:
\documentclass[a4paper,12pt,twoside]{article}
\usepackage[norsk]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{setspace}
\onehalfspacing
\usepackage{parskip}
\usepackage{fontawesome}
\usepackage{graphicx,tikz}
\definecolor{color1}{rgb}{0.22,0.45,0.70} %blå fra cvmodern.
\usepackage{lipsum}
\begin{document}
\setcounter{page}{0}
\pagenumbering{roman}
%Contact info:
\noindent
\begin{minipage}[t][0.8cm][b]{0.33\textwidth} {\small name} \\ {\small address} \\ \small{post number}
\end{minipage}%
\begin{minipage}[t][0.8cm][b]{0.33\textwidth}\faMobilePhone \hspace{2.2mm} {\small666 66 666}\\ \faEnvelope \hspace{0.2mm} \small{[email protected]}
\end{minipage}%
\begin{minipage}[t][0.8cm][b]{0.33\textwidth}\hfill {\small \today}
\end{minipage}
% thumb index:
\begin{tikzpicture}[remember picture,overlay]
\draw [color=color1, fill=color1]
([xshift=-35pt]current page.north east) rectangle (current page.south east);
\node[rotate=90,white,font=\Large\bfseries,anchor=south east]
at ([yshift=-10pt,xshift=-5pt]current page.north east)
{Application};
\end{tikzpicture}
\vspace{0.3cm}
\textbf{Application on the job} \\
\lipsum
\begin{tikzpicture}[remember picture,overlay]
\draw [color=color1, fill=color1]
([xshift=-30pt]current page.north east) rectangle (current page.south east);
\node[rotate=90,white,font=\Large\bfseries,anchor=south east]
at ([yshift=-10pt,xshift=-5pt]current page.north east)
{Appendix};
\end{tikzpicture}
\end{document}
结果:
当然,新的命令可以简化这项工作:
\newcommand\ThumbIndex[1]{%
\begin{tikzpicture}[remember picture,overlay]
\draw [color=color1, fill=color1]
([xshift=-35pt]current page.north east) rectangle (current page.south east);
\node[rotate=90,white,font=\Large\bfseries,anchor=south east]
at ([yshift=-10pt,xshift=-5pt]current page.north east)
{#1};
\end{tikzpicture}%
}
并且,在文件中,
\ThumbIndex{Application}
和
\ThumbIndex{Apprndix}
在所需的位置。完整代码:
\documentclass[a4paper,12pt,twoside]{article}
\usepackage[norsk]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{setspace}
\onehalfspacing
\usepackage{parskip}
\usepackage{fontawesome}
\usepackage{graphicx,tikz}
\definecolor{color1}{rgb}{0.22,0.45,0.70} %blå fra cvmodern.
\usepackage{lipsum}
\newcommand\ThumbIndex[1]{%
\begin{tikzpicture}[remember picture,overlay]
\draw [color=color1, fill=color1]
([xshift=-35pt]current page.north east) rectangle (current page.south east);
\node[rotate=90,white,font=\Large\bfseries,anchor=south east]
at ([yshift=-10pt,xshift=-5pt]current page.north east)
{#1};
\end{tikzpicture}%
}
\begin{document}
\setcounter{page}{0}
\pagenumbering{roman}
%Contact info:
\noindent
\begin{minipage}[t][0.8cm][b]{0.33\textwidth} {\small name} \\ {\small address} \\ \small{post number}
\end{minipage}%
\begin{minipage}[t][0.8cm][b]{0.33\textwidth}\faMobilePhone \hspace{2.2mm} {\small666 66 666}\\ \faEnvelope \hspace{0.2mm} \small{[email protected]}
\end{minipage}%
\begin{minipage}[t][0.8cm][b]{0.33\textwidth}\hfill {\small \today}
\end{minipage}
\ThumbIndex{Application};
\vspace{0.3cm}
\textbf{Application on the job} \\
\lipsum
\ThumbIndex{Appendix};
\end{document}
如果要移动拇指索引,则可以使用另一个参数,或者使移位依赖于分段单位计数器:
\newcommand\ThumbIndex[2]{%
\begin{tikzpicture}[remember picture,overlay]
\draw [color=color1, fill=color1]
([xshift=-35pt]current page.north east) rectangle (current page.south east);
\node[rotate=90,white,font=\Large\bfseries,anchor=south east]
at ([shift={#2}]current page.north east)
{#1};
\end{tikzpicture}%
}
进而
\ThumbIndex{Application}{(-5pt,-10pt)};
和
\ThumbIndex{Appendix}{(-5pt,-120pt)};
以下代码的结果:
完整代码:
\documentclass[a4paper,12pt,twoside]{article}
\usepackage[norsk]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{setspace}
\onehalfspacing
\usepackage{parskip}
\usepackage{fontawesome}
\usepackage{graphicx,tikz}
\definecolor{color1}{rgb}{0.22,0.45,0.70} %blå fra cvmodern.
\usepackage{lipsum}
\newcommand\ThumbIndex[2]{%
\begin{tikzpicture}[remember picture,overlay]
\draw [color=color1, fill=color1]
([xshift=-35pt]current page.north east) rectangle (current page.south east);
\node[rotate=90,white,font=\Large\bfseries,anchor=south east]
at ([shift={#2}]current page.north east)
{#1};
\end{tikzpicture}%
}
\begin{document}
\setcounter{page}{0}
\pagenumbering{roman}
%Contact info:
\noindent
\begin{minipage}[t][0.8cm][b]{0.33\textwidth} {\small name} \\ {\small address} \\ \small{post number}
\end{minipage}%
\begin{minipage}[t][0.8cm][b]{0.33\textwidth}\faMobilePhone \hspace{2.2mm} {\small666 66 666}\\ \faEnvelope \hspace{0.2mm} \small{[email protected]}
\end{minipage}%
\begin{minipage}[t][0.8cm][b]{0.33\textwidth}\hfill {\small \today}
\end{minipage}
\ThumbIndex{Application}{(-5pt,-10pt)};
\vspace{0.3cm}
\textbf{Application on the job} \\
\lipsum
\ThumbIndex{Appendix}{(-5pt,-120pt)};
\end{document}
评论
也许
background
包也可以在这里使用,但是根据问题中的信息,我无法决定。\small
和类似的开关不接收参数。\small{text}
您应该使用而不是{\small text}
。我
%
在前两个 s 的末尾添加了一些minipage
,以防止虚假的空格导致\hbox
s 过满。