超链接未正确重定向

超链接未正确重定向

重定向到 EDM(目标)焦点后,PDF 应如下所示 但目前的情况是这样的。EDM 不再是焦点

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

答案1

您的代码中有很多错误和一些误解。

  1. scrpage2用于 KOMA-Script 类,如scrartcl。它已过时。您应该改用fancyhdr(对于不使用 KOMA-Script 的文档)或者您需要调用包scrextend才能使用包scrlayer-scrpage( 的后继scrpage2)。
  2. caption2已过时,请改用包caption
  3. 您的包裹hyperref应该最后被调用!
  4. 您使用了很多setlength命令。您最好使用包来实现这一点。请参阅带有...geometry的文档。texdoc geometry
  5. 您在使用字幕时犯了一些错误longtable:字幕末尾longtable需要一个。\\
  6. 您不能p仅在 中使用longtable,它必须是类似于 的。根据您的需要p{7.5cm}更改值!7.5cm
  7. 您在代码中使用了很多包和命令。您知道每个包和命令的作用吗?如果不知道,请删除/注释它们,检查布局中的变化并阅读每个包的文档!

以下更正后的代码编译时没有错误(但布局可能与您想要的不同):

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

及其结果:

产生的长表

现在对您的使用进行一个注释\hyperref[frog]{frog}:如果您希望能够创建一个指向特殊单词的链接,例如frog在您的文本中,您需要使用hypertarget来定义链接的目标frog\hypertarget{frog}{text of link frog}。然后,指向目标的链接将按照tex 代码中的格式frog写入...\hyperlink{frog}{text to link to frog}

正如您在以下较短的 mwe 中看到的,根据您更改的代码,您可以使用

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

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

在你的两个表中。

附完整代码

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

您将获得以下带有蓝色链接的起始页:

带有链接的页面

点击红色圆圈标记的链接后,您将看到以下页面:

链接页面

红色箭头所指的就是目标。注意显示的页面取决于使用的 pdf 查看器,我使用的是 SumatraPDF。

相关内容