0

enter image description here The link of 2nd box is worked but not the 1st one. I want to link the title, so that from any position using the BCMP link word I can reach in the title. Full source file --

    \documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
    \usepackage{xltxtra,xunicode}
  \else
    \usepackage{fontspec}
  \fi
  \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  \newcommand{\euro}{€}
\fi
% use microtype if available
\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
\usepackage{longtable,booktabs}
\ifxetex
  \usepackage[setpagesize=false, % page size defined by xetex
              unicode=false, % unicode breaks when used with xetex
              xetex]{hyperref}
\else
  \usepackage[unicode=true]{hyperref}
\fi
\hypersetup{breaklinks=true,
            bookmarks=true,
            pdfauthor={},
            pdftitle={BCMP(3)},
            colorlinks=true,
            citecolor=blue,
            urlcolor=blue,
            linkcolor=magenta,
            pdfborder={0 0 0}}
\urlstyle{same}  % don't use monospace font for urls
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\setcounter{secnumdepth}{0}
\usepackage{pagecolor}

% Set background colour (of the page)
\definecolor{weirdbgcolor}{HTML}{FCF4F0}
\pagecolor{weirdbgcolor}

% Make bold text appear in a particular colour
\definecolor{boldcolor}{HTML}{6E0002}
\let\realtextbf=\textbf
\renewcommand{\textbf}[1]{\textcolor{boldcolor}{\realtextbf{#1}}}

% Use underlines instead of emphasis (ugh)
\renewcommand{\emph}[1]{\underline{#1}}

% % Use fixed-width font by default
% \renewcommand*\familydefault{\ttdefault}

\hyperdef{}{BCMP}{\title{BCMP(3)}\label{BCMP}}
\author{}
\date{}

\begin{document}
\maketitle

\begin{longtable}[c]{@{}lll@{}}
\toprule\addlinespace
\hyperdef{}{BCMP}{BCMP\label{BCMP}}(3) & Linux Programmer's Manual & BCMP(3)
\\\addlinespace
\bottomrule
\end{longtable}

\hyperdef{}{NAME}{\section{\hyperref[NAME]{NAME}}\label{NAME}}

bcmp - compare byte sequences

\hyperdef{}{SYNOPSIS}{\section{\hyperref[SYNOPSIS]{SYNOPSIS}}\label{SYNOPSIS}}

\begin{verbatim}
#include <strings.h>

int bcmp(const void *s1, const void *s2, size_t n);
\end{verbatim}

\hyperdef{}{DESCRIPTION}{\section{\hyperref[DESCRIPTION]{DESCRIPTION}}\label{DESCRIPTION}}

\hyperref[BCMP]{BCMP}The \textbf{bcmp}() function compares the two byte sequences \emph{s1}
and \emph{s2} of length \emph{n} each. If they are equal, and in
particular if \emph{n} is zero, \textbf{bcmp}() returns 0. Otherwise it
returns a nonzero result.

\hyperdef{}{RETURNux5fVALUE}{\section{\hyperref[RETURNux5fVALUE]{RETURN
VALUE}}\label{RETURNux5fVALUE}}

The \textbf{bcmp}() function returns 0 if the byte sequences are equal,
otherwise a nonzero result is returned.

\hyperdef{}{CONFORMINGux5fTO}{\section{\hyperref[CONFORMINGux5fTO]{CONFORMING
TO}}\label{CONFORMINGux5fTO}}

4.3BSD. This function is deprecated (marked as LEGACY in POSIX.1-2001):
use \textbf{memcmp}(3) in new programs. POSIX.1-2008 removes the
specification of \textbf{bcmp}().

\hyperdef{}{SEEux5fALSO}{\section{\hyperref[SEEux5fALSO]{SEE
ALSO}}\label{SEEux5fALSO}}

\textbf{memcmp}(3), \textbf{strcasecmp}(3), \textbf{strcmp}(3),
\textbf{strcoll}(3), \textbf{strncasecmp}(3), \textbf{strncmp}(3)

\hyperdef{}{COLOPHON}{\section{\hyperref[COLOPHON]{COLOPHON}}\label{COLOPHON}}
\hyperref[BCMP]{BCMP}

This page is part of release 3.54 of the Linux \emph{man-pages} project.
A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.

\begin{longtable}[c]{@{}ll@{}}
\toprule\addlinespace
2008-08-06 & Linux
\\\addlinespace
\bottomrule
\end{longtable}

\end{document}

This is the extended question of How to create pdf from Linux man pages so that style is presereved?

alhelal
  • 2,451

1 Answers1

3

From the shown hacking with \hyperdef I do not really understand, what you are doing. But you should note, \title{…} does not print anything but only define an internal value that is used inside \maketitle to print the title. So if you want to have a hyper target with the title, the definition of the hyper target has so be inside the \title argument. For the same reason a \label in the document preamble behind \title{…} is useless like each other \label before \begin{document}.

Also the hyper target definitions to section titles would be better defined inside the \section argument but in this case such a definition mostly is not needed, because you can use \nameref to link to the name of a section and \autoref or \ref to link to the section number:

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{hyperref}
\title{\hypertarget{BCMP}{BCMP(3)}}
\author{}
\date{}

\begin{document}
\maketitle

\section{NAME}\label{NAME}

\clearpage

\section{Next}\label{sec:Next}

\hyperlink{BCMP}{BCMP} and \nameref{NAME} to \autoref{NAME}.


\end{document}

Last page with links

Schweinebacke
  • 26,336