Generalmultiple use of \ref & \label for headlines?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
thomasle
Posts: 4
Joined: Fri Feb 26, 2016 4:48 pm

multiple use of \ref & \label for headlines?

Post by thomasle »

Hello,

I am not new to Latex, but actually can't solve one issue myself.
Somehow I can't use \label and \ref togehther with hyperlinks...

The thing is I'd like to make some kind of newsletter.
One sidebar shall give an overview about the topics, including hyperlinks:

Code: Select all

\hypertarget{contents}{\textbf{{\large Overview\ldots}}} 
\begin{itemize}
\item \hyperlink{news1}{Topic A}
\item \hyperlink{news2}{Topic B}
\item \hyperlink{news3}{Topic C}
...
\end{itemize}
Later in the document where the article begins it is necessary to retype the topics headlines, instead of using some kind of link or label.

Code: Select all

\hypertarget{news1}{\heading{Topic A}{6pt}} 
...
\hypertarget{news2}{\heading{Topic B}{6pt}}
...
\hypertarget{news3}{\heading{Topic C}{6pt}} 
So if you don't pay full attention there could be differences.
That is why I would like to use some kind of labels and references.
The big question is: how?

Any hint is welcome.

Thomas

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

multiple use of \ref & \label for headlines?

Post by cgnieder »

Can you provide a Infominimal working example (a rather small but complete document, follow the link for details) which we can copy and test?

Regards
site moderator & package author
thomasle
Posts: 4
Joined: Fri Feb 26, 2016 4:48 pm

multiple use of \ref & \label for headlines?

Post by thomasle »

Hi Clemens,

thanks for your reply. I shortened the newsletter template.
Long story short, is there any possibility not to have each topic twice?

Code: Select all

\documentclass[10pt]{article} % The default font size is 10pt; 11pt and 12pt are alternatives



\input{structure.tex} % Include the document which specifies all packages and structural customizations for this template

\begin{document}

%----------------------------------------------------------------------------------------
%	HEADER IMAGE
%----------------------------------------------------------------------------------------

\begin{figure}[H]
\begin{addmargin}{-0.075\textwidth} % Graphics field wider than text field
% my graphics here
\end{addmargin}
\end{figure}

\Large\textbf{Newsletter}




%----------------------------------------------------------------------------------------
%	SIDEBAR - 1st PAGE
%----------------------------------------------------------------------------------------

\begin{minipage}[t]{.28\linewidth} % Mini page taking up 25% of the actual page
\begin{mdframed}[style=sidebar,frametitle={}] % Sidebar box


%-----------------------------------------------------------

\hypertarget{contents}{\textbf{{\large Inhalt\ldots}}} % \hypertarget provides a label to reference using \hyperlink{label}{link text}
\begin{itemize}
\normalsize
\item \hyperlink{news0}{pre...}
\item \hyperlink{news1}{Topic1}
\item \hyperlink{news2}{Topic2}
\item \hyperlink{news3}{Topic3}
\item \hyperlink{next-times}{whatsnext\ldots}
\end{itemize}

\end{mdframed}


\end{minipage}\hfill % End the sidebar mini page 
%
%----------------------------------------------------------------------------------------
%	MAIN BODY - 1st PAGE
%----------------------------------------------------------------------------------------
%
\begin{minipage}[t]{.7\linewidth} % Mini page taking up 70% of the actual page


\hypertarget{news0}{\heading{Pre...}{6pt}} % \hypertarget provides a label to reference using \hyperlink{label}{link text}

This is what ths newsletter is about


\BackToContents % Link back to the contents of the newsletter



\hypertarget{news1}{\heading{Topic1}{6pt}} % \hypertarget provides a label to reference using \hyperlink{label}{link text}

dead text esfr sdf asdfgdetu jguj dfg srdfqw e w e sgdstg h j gfhrs f das f adf sfad ghrtfg hj tdugjk zu kjheatrd gf qewrd qwrt gezrts jdtku kjgd jhgdrgf aer hgsjtzuk zdfhgws efdqwe dwetg hrszkj duz srgh we 

\BackToContents % Link back to the contents of the newsletter


\hypertarget{news2}{\heading{Topic2}{6pt}} % \hypertarget provides a label to reference using \hyperlink{label}{link text}

dead text esfr sdf asdfgdetu jguj dfg srdfqw e w e sgdstg h j gfhrs f das f adf sfad ghrtfg hj tdugjk zu kjheatrd gf qewrd qwrt gezrts jdtku kjgd jhgdrgf aer hgsjtzuk zdfhgws efdqwe dwetg hrszkj duz srgh we 

\BackToContents % Link back to the contents of the newsletter

\end{minipage} % End the main body - first page mini page


\end{document} 
BR, Thomas
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: multiple use of \ref & \label for headlines?

Post by cgnieder »

Sadly I can't compile and test – the example isn't minimal and depends on files I don't have…

Regards
site moderator & package author
thomasle
Posts: 4
Joined: Fri Feb 26, 2016 4:48 pm

multiple use of \ref & \label for headlines?

Post by thomasle »

Hi Clemens,

you are right, my example unfortually was not minimal and incomplmete. :(
Sorry for that, so please one last try with this working one:

Code: Select all

\documentclass[10pt]{article} % The default font size is 10pt; 11pt and 12pt are alternatives

\usepackage{hyperref}

\newcommand{\heading}[2]{ % Define the \heading command
\vspace{#2} % White space above the heading
{\begin{center}\Large\textbf{#1}\end{center}} % The heading style
\vspace{#2} % White space below the heading
}
\begin{document}


\Large\textbf{Newsletter}

\hypertarget{contents}{\textbf{{\large Inhalt\ldots}}} % \hypertarget provides a label to reference using \hyperlink{label}{link text}
\begin{itemize}
\normalsize
\item \hyperlink{news0}{pre...}
\item \hyperlink{news1}{Topic1}
\item \hyperlink{news2}{Topic2}
\item \hyperlink{news3}{Topic3}
\item \hyperlink{next-times}{whatsnext}
\end{itemize}


\hypertarget{news0}{\heading{Pre...}{6pt}} % \hypertarget provides a label to reference using \hyperlink{label}{link text}

This is what this newsletter is about


\hypertarget{news1}{\heading{Topic1}{6pt}} % \hypertarget provides a label to reference using \hyperlink{label}{link text}

dead text esfr sdf asdfgdetu jguj dfg srdfqw e w e sgdstg h j gfhrs f das f adf sfad ghrtfg hj tdugjk zu kjheatrd gf qewrd qwrt gezrts jdtku kjgd jhgdrgf aer hgsjtzuk zdfhgws efdqwe dwetg hrszkj duz srgh we 


\hypertarget{news2}{\heading{Topic2}{6pt}} % \hypertarget provides a label to reference using \hyperlink{label}{link text}

dead text esfr sdf asdfgdetu jguj dfg srdfqw e w e sgdstg h j gfhrs f das f adf sfad ghrtfg hj tdugjk zu kjheatrd gf qewrd qwrt gezrts jdtku kjgd jhgdrgf aer hgsjtzuk zdfhgws efdqwe dwetg hrszkj duz srgh we 


\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: multiple use of \ref & \label for headlines?

Post by Johannes_B »

section, you are looking for the very simple section and tableofcontents. LaTeX does this kind of stuff for you.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
thomasle
Posts: 4
Joined: Fri Feb 26, 2016 4:48 pm

Re: multiple use of \ref & \label for headlines?

Post by thomasle »

Thanks Johannes, a TOC is similar to what I was looking for, except I found no way of including an itemized TOC into a minipage with hyperlinks.
Post Reply