2

PDF should look like this, after redirecting where EDM (Target) is in focus But currently, it is looking like this. Where EDM is out of focus

\documentclass[a4paper, twoside]{article}
\pagenumbering{roman}
\usepackage[english]{babel}
 \usepackage{titletoc} 
 \usepackage{titlesec} 
 \usepackage{ltxtable}
 \usepackage{filecontents} 
 \usepackage{lscape}
 \usepackage{booktabs}
 \usepackage{color} 
 \usepackage{tabularx} 


 \usepackage{hyperref} 
\hypersetup{colorlinks, linkcolor=link, filecolor=link, urlcolor=link, citecolor=link, pdfpagemode=UseOutlines, pdfcreator=TrainBraC, pdfauthor={E. Hohmann}, pdfproducer=PDFLaTeX, pdftitle=Schulungsprojekt, pdfsubject=Brake calculation}
\begin{document}
\section*{Table of content}\startcontents\printcontents{l}{1}{\setcounter{tocdepth}{3}}
\clearpage
\phantomsection\section*{List of modifications}\addcontentsline{toc}{section}{List of modifications}
\begin{longtable}{c|c|c|p{7.5cm}}
Revision&Date&File processed by&Notes\hline

01&\hyperref[lb:EDM]{EDM}&E. Hohmann&Some random  text\\
\hline

\end{longtable}




\clearpage
\section{Information of Software Versions}
\subsection{Information of Versions}


\begin{longtable}{|c|c|c|c|}
\caption{Version of brake system DLLs}
\hline
TrainPart&Type&Version&Designation\hline

\endfirsthead
\caption{ContinuationVersion of brake system DLLs}
\hline
TrainPart&Type&Version&Designation\hline

\endhead
\hline
\multicolumn{4}{|c|}{Continued on next page}
\hline
\endfoot
\hline
\multicolumn{4}{c}{}
\endlastfoot
M&Electrodynamic brake&1.0.1&\phantomsection{ED M}\label{lb:EDM}\\
&Tread brake unit&1.0.0&PECM\\
&Tread brake unit&1.0.0&PECMP\\
\hline
N1&Tread brake unit&1.0.0&PECN1\\
&Tread brake unit&1.0.0&PECN1P\\
&Electrodynamic brake&1.0.1&ED N1\\
\hline
T&Disc brake&1.0.0&UPT\\
&Tread brake unit&1.0.0&PECT\\
&Tread brake unit&1.0.0&PECTP\\
\hline
N2&Tread brake unit&1.0.0&PECN2\\
&Tread brake unit&1.0.0&PECN2P\\
&Electrodynamic brake&1.0.1&ED N2\\
\hline

\end{longtable}



\end{document}
4
  • the code does not compile
    – user186389
    Apr 24, 2019 at 11:39
  • also hyperref should be loaded last
    – user186389
    Apr 24, 2019 at 11:40
  • 3
    I tried to clean up the code display a bit. The \makeatletter\\\\ looks extremely suspicious, do you really have that in your code? Note also that you seem to load a lot of packages. Do you need all of them? hyperref should generally be loaded last. There are also a few packages (scrpage2) that are outdated
    – moewe
    Apr 24, 2019 at 11:49
  • If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓).
    – Mensch
    Jul 12, 2019 at 14:51

1 Answer 1

3

You have a lot of errors in your code and some missunderstanding.

  1. Package scrpage2 is used in KOMA-Script classes like scrartcl. It is obsolete. You should use instead fancyhdr (for documents not using KOMA-Script) or you need to call package scrextend to be able to use then package scrlayer-scrpage (the successor of scrpage2).
  2. Package caption2 is obsolete, use instead package caption!
  3. Package hyperref should be called in your case last!
  4. You use a lot of setlength commands. You should better use package geometry for this. See the documentation with texdoc geometry ...
  5. You have some eroors in the usage of captions for longtable: Captions in longtable needs an \\ at the end.
  6. You can not use p only in longtable, it must be something like p{7.5cm}. Change the value 7.5cm for your needs!
  7. You are using a lot of packages and commands in your code. Do you know from each one what is does? If not, delete/comment them, check the changings in the layout and read the documentations of each package!

The following corrected code compiles without errors (but the layout might differ to that what you want):

\documentclass[a4paper, twoside]{article}

\usepackage[latin1]{inputenc}
\usepackage[OT1]{fontenc}
\usepackage[english]{babel}

\usepackage[pdftex]{graphicx}
\usepackage{helvet}
\usepackage{titletoc}
\usepackage{titlesec}

\usepackage{ltxtable}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{color}

\usepackage{pdfpages}
%\usepackage[flushleft]{caption2} % <============================== ?????
\usepackage{caption} % <======== caption2 outdated, use caption instead!
\usepackage{multirow}
\usepackage{lastpage}
\usepackage{afterpage}
\usepackage{ifthen}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{needspace}
\usepackage{tabularx}

% only used in KOMA-Script with class `scrartcl` or with package `scrextend`
%\usepackage{scrextend}
%\usepackage{scrlayer-scrpage} % <======================================= scrpage2 obsolet
%\pagestyle{scrheadings}
%\setheadsepline{0.25pt}
%\setfootsepline{0.25pt}

\usepackage{hyperref}

% <===================================== Why not using package geometry?
\setlength{\topmargin}{-0.9in}
\setlength{\textwidth}{470pt}
\setlength{\oddsidemargin}{0pt}
\setlength{\textheight}{640pt}
\setlength{\headheight}{70pt}
\setlength{\footskip}{50pt}
\setlength{\evensidemargin}{0pt} \setlength{\parindent}{0pt}
\setlength{\parskip}{1ex plus 1ex minus 1ex}

 \setcounter{LTchunksize}{20}
 \newlength{\minrowheight}
 \newlength{\tblheightcaption}
 \newlength{\tblcwA}
 \newlength{\tblcwB}
 \newlength{\tmp}

 \renewcommand{\familydefault}{\sfdefault}
 \renewcommand{\baselinestretch}{1.2}
 \renewcommand{\arraystretch}{1.0}
 \renewcommand{\encodingdefault}{T1}
 \renewcommand{\thefigure}{\thesection{}.\arabic{figure}}
 \renewcommand{\thetable}{\thesection{}.\arabic{table}}
 \renewcommand{\captionsize}{\normalsize}
 \renewcommand{\d}{d}
 \renewcommand{\sectionmark}[1]{\markboth{\emph{#1}}{}}
 \renewcommand\floatpagefraction{0.8}
 \renewcommand\textfraction{0.2} 
 \renewcommand\topfraction{0.8}
 \renewcommand\bottomfraction{0.3}

 \setcounter{totalnumber}{20}
 \setcounter{topnumber}{15}
 \setcounter{bottomnumber}{5}

 \makeatletter
 \setlength{\@fptop}{2pt} % float at the top
 \setlength{\@fpsep}{0pt}
 \setlength{\@fpbot}{7pt}
 \makeatother

 \clubpenalty = 100
 \widowpenalty = 100
 \displaywidowpenalty = 1000

 \newcolumntype{I}{!{\vrule width 1.5pt}}
 \newcommand{\amp}{&}
 \newcommand{\gt}{\>}
 \newcommand{\mlt}{<}
 \newcommand{\mgt}{>}
 \newcommand{\mue}{\mu}
 \newcommand{\Mue}{\Mu}
 \newcommand{\nue}{\nu}
 \newcommand{\Nue}{Nu}

 \definecolor{link}{rgb}{0,0,1} 

\hypersetup{%
  colorlinks, linkcolor=link, filecolor=link, urlcolor=link, citecolor=link,
  pdfpagemode=UseOutlines,
  pdfcreator=TrainBraC, pdfauthor={E. Hohmann}, pdfproducer=PDFLaTeX,
  pdftitle=Schulungsprojekt, pdfsubject=Brake calculation
}
\graphicspath{ {./images/} }

\makeatletter % <=======================================================
\AddToShipoutPicture{ \setlength{\@tempdimb}{.5\paperwidth} \setlength{\@tempdimc}{.5\paperheight} \setlength{\unitlength}{1pt} \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){ \makebox(0,0){\rotatebox{45}{\textcolor[gray]{0.75}{\fontsize{3cm}{3cm}\selectfont{Draft}}}} } }
\makeatother % <========================================================

\pagenumbering{roman}


\begin{document}
\section*{Table of content}\startcontents\printcontents{l}{1}{\setcounter{tocdepth}{3}}
\clearpage
\phantomsection\section*{List of modifications}\addcontentsline{toc}{section}{List of modifications}
\begin{longtable}{c|c|c|p{7.5cm}} % <===================================
Revision & Date & File processed by & Notes \\ \hline % <===============
02       &\hyperref[frog]{frog}
                & E. Hohmann        &Test of new UNIBRAKE calculation method of WZ + PEC7 brake units, combination according to  force/pressure equation\\
\hline
\end{longtable}

\clearpage

\section{Information of Software Versions}
\subsection{Information of Versions}

\begin{longtable}{|c|c|c|c|}
  \caption{Version of brake system DLLs} \\ % <===========================
  \hline
  TrainPart&Type&Version&Designation\\ \hline % <=========================
\endfirsthead
  \caption{ContinuationVersion of brake system DLLs} \\ % <===============
  \hline
  TrainPart&Type&Version&Designation\\ \hline % <=========================
\endhead
  \hline
  \multicolumn{4}{|c|}{Continued on next page} \\ % <=====================
  \hline
\endfoot
  \hline
  \multicolumn{4}{c}{} \\ % <=============================================
\endlastfoot
M & Electrodynamic brake & 1.0.1 & \phantomsection\label{frog}Frog\\
  & Tread brake unit     & 1.0.0 & PECM\\
  & Tread brake unit     & 1.0.0 & PECMP\\
\hline
N1&Tread brake unit&1.0.0&PECN1\\
&Tread brake unit&1.0.0&PECN1P\\
&Electrodynamic brake&1.0.1&ED N1\\
\hline
T&Disc brake&1.0.0&UPT\\
&Tread brake unit&1.0.0&PECT\\
&Tread brake unit&1.0.0&PECTP\\
\hline
N2&Tread brake unit&1.0.0&PECN2\\
&Tread brake unit&1.0.0&PECN2P\\
&Electrodynamic brake&1.0.1&ED N2\\
\hline
\end{longtable}

\end{document}

and its result:

resulting longtable

Now a remark to your used \hyperref[frog]{frog}: if you want to be able to create a link to a special word, for example frog in your text, you need to use hypertarget to define the target for a link frog: \hypertarget{frog}{text of link frog}. The link to target frog is then writen as \hyperlink{frog}{text to link to frog} in the tex code ...

As you can see in the following shorter mwe, based on your changed code, you can use

\hyperlink{lb:EDM}{EDM} %\hyperref[lb:EDM]{EDM}

and

\hypertarget{lb:EDM}{ED M} \\ %\phantomsection{ED M}\label{lb:EDM}\\

in your both tables.

With the complete code

\documentclass[a4paper, twoside]{article}
\pagenumbering{roman}
\usepackage[english]{babel}
\usepackage{titletoc} 
\usepackage{titlesec} 
\usepackage{ltxtable}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{color} 
\usepackage{tabularx} 

\usepackage{hyperref}

\definecolor{link}{rgb}{0,0,1}
\hypersetup{%
  colorlinks, 
  linkcolor=link, filecolor=link, urlcolor=link, citecolor=link, 
  pdfpagemode=UseOutlines, pdfcreator=TrainBraC, pdfauthor={E. Hohmann}, 
  pdfproducer=PDFLaTeX, pdftitle=Schulungsprojekt, 
  pdfsubject=Brake calculation
}
\pagenumbering{roman}


\begin{document}
\section*{Table of content}\startcontents\printcontents{l}{1}{\setcounter{tocdepth}{3}}
\clearpage
\phantomsection
\section*{List of modifications}
\addcontentsline{toc}{section}{List of modifications}
\begin{longtable}{c|c|c|p{7.5cm}} % <===================================
Revision & Date & File processed by & Notes \\ \hline % <===============
02       & \hyperlink{lb:EDM}{EDM} %\hyperref[lb:EDM]{EDM} <============
                & E. Hohmann        &Test of new UNIBRAKE calculation method of WZ + PEC7 brake units, combination according to  force/pressure equation\\
\hline
\end{longtable}

\clearpage

\section{Information of Software Versions}
\subsection{Information of Versions}

\begin{longtable}{|c|c|c|c|}
  \caption{Version of brake system DLLs} \\ % <===========================
  \hline
  TrainPart&Type&Version&Designation\\ \hline % <=========================
\endfirsthead
  \caption{ContinuationVersion of brake system DLLs} \\ % <===============
  \hline
  TrainPart&Type&Version&Designation\\ \hline % <=========================
\endhead
  \hline
  \multicolumn{4}{|c|}{Continued on next page} \\ % <=====================
  \hline
\endfoot
  \hline
  \multicolumn{4}{c}{} \\ % <=============================================
\endlastfoot
M & Electrodynamic brake & 1.0.1 & \hypertarget{lb:EDM}{ED M} \\ %\phantomsection{ED M}\label{lb:EDM}\\
  & Tread brake unit     & 1.0.0 & PECM\\
  & Tread brake unit     & 1.0.0 & PECMP\\
\hline
N1& Tread brake unit     & 1.0.0 & PECN1\\
  & Tread brake unit     & 1.0.0 & PECN1P\\
  & Electrodynamic brake & 1.0.1 & ED N1\\
\hline
T & Disc brake           & 1.0.0 & UPT\\
  & Tread brake unit     & 1.0.0 & PECT\\
  & Tread brake unit     & 1.0.0 & PECTP\\
\hline
N2& Tread brake unit     &1.0.0  &PECN2\\
  & Tread brake unit     &1.0.0  &PECN2P\\
  & Electrodynamic brake &1.0.1  &ED N2\\
\hline
\end{longtable}

\end{document}

you get the following starting page with the blue link:

page with link

After clicking on the link marked with the red circle you get the following page shown:

linked page

marked with the red arrow is the target. Note that the showed page can be depend on the used pdf viewer, I'm using SumatraPDF.

2
  • Still facing same issue. I am using Adobe reader.
    – sameerk
    May 3, 2019 at 12:15
  • With given code, I am able to redirect to a correct page, but when I am setting 100% as a zoom and click on the link, it redirects to a page but destined item (EDM in this case) is out of focus. For reference find screenshot number 2.
    – sameerk
    May 4, 2019 at 9:07

You must log in to answer this question.

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