LyXHyperlink problem

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
effeksys
Posts: 3
Joined: Wed Jul 06, 2011 7:53 pm

Hyperlink problem

Post by effeksys »

Hello.

I've a problem with hyperlinks in my document.
If i insert Hyperlinka (Insert->Hyperlinks), the following errors occurs:

Code: Select all

LaTeX Error: Option clash for package babel.
LaTeX Error: Missing \begin{document}.
You can't use `macro parameter character #' in horizontal mode.
You can't use `macro parameter character #' in horizontal mode.
Extra \else.
You can't use `macro parameter character #' in horizontal mode.
I use a lyx template from the TU Dresden, with following Latex-Preamble(Document->settings->Latex-Preamble):

Code: Select all

% verschieden Symbole, Zeichen wie (c), €
\usepackage{textcomp}
\usepackage{ %a4wide,
            ellipsis, fixltx2e, mparhack,   %Fehlerkorrektur für Marginalien
            booktabs, longtable             %schönere Tabellen
}  
\usepackage[automark]{scrpage2}
%\automark[chapter]{chapter}
\clearscrheadfoot
\ohead{\\\headmark}
\ihead{\includegraphics[scale=0.1]{pics/uni_logo.pdf}}%\pagemark}
\ofoot[\pagemark]{\pagemark}

%Kurzfassung und Abstract (englisch) auf eine Seite
\renewenvironment{abstract}{
    \@beginparpenalty\@lowpenalty
      \begin{center}
        \normalfont\sectfont\nobreak\abstractname
        \@endparpenalty\@M
      \end{center}
}{
    \par
}

% schönerer Blocksatz!!
\usepackage{microtype}

\usepackage{ifpdf} % part of the hyperref bundle
\ifpdf % if pdflatex is used

%set fonts for nicer pdf view
 \IfFileExists{lmodern.sty}{\usepackage{lmodern}}
  {\usepackage[scaled=0.92]{helvet}
    \usepackage{mathptmx}
    \usepackage{courier} }
\fi

 % the pages of the TOC are numbered roman
 % and a pdf-bookmark for the TOC is added
 \pagenumbering{roman}
 \let\myTOC\tableofcontents
 \renewcommand\tableofcontents{
   %\pdfbookmark[1]{Contents}{}
   \myTOC
   \clearpage
   \pagenumbering{arabic}}

%Bezeichungen anpassen
%Babelpaket muß zuvor geladen werden
\usepackage[ngerman]{babel}
\addto\captionsngerman{ 
\renewcommand{\figurename}{Abb.}% 
\renewcommand{\tablename}{Tab.}% 
\renewcommand{\abstractname}{Kurzfassung}
%\renewcommand{\nomname}{Abkürzungen}
}

% Alle Querverweise und URLs als Link darstellen
% In der PDF-Ausgabe
 \usepackage[colorlinks=true, bookmarks, bookmarksnumbered, bookmarksopen, bookmarksopenlevel=1,
  linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,
  pdfpagelayout=OneColumn, pdfnewwindow=true,
  pdfstartview=XYZ, plainpages=false, pdfpagelabels,
  pdfauthor={LyX Team}, pdftex,
  pdftitle={LyX's Figure, Table, Floats, Notes, and Boxes manual},
  pdfsubject={LyX-documentation about figures, tables, floats, notes, and boxes},
  pdfkeywords={LyX, Tables, Figures, Floats, Boxes, Notes}]{hyperref}

%mehr Platz zwischen Überschrift und Tabelle
\newcommand{\@ldtable}{}
\let\@ldtable\table
\renewcommand{\table}{ %
                 \setlength{\@tempdima}{\abovecaptionskip} %
                 \setlength{\abovecaptionskip}{\belowcaptionskip} %
                 \setlength{\belowcaptionskip}{\@tempdima} %
                 \@ldtable}
If i insert hyperlinks in a new documents, no errors occurs...
Can anybody help me?

Thanks!
effeksys

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

5gon12eder
Posts: 126
Joined: Sun Feb 13, 2011 8:36 pm

Hyperlink problem

Post by 5gon12eder »

It doesn't get clear from the code you've posted (which, by the way, also isn't "minimal" by no means) but the error message you show makes me assume that you've written something like

Code: Select all

\href{http://en.wikipedia.org/wiki/Dog#Taxonomy}{http://en.wikipedia.org/wiki/Dog#Taxonomy}
which is invalid code. The second argument of \href must be proper LaTeX code, so characters like # have to be written as their LaTeX macro, which, in this case, is \#.

Best
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Hyperlink problem

Post by sommerfee »

effeksys wrote:LaTeX Error: Option clash for package babel.
You are loading the babel package twice. Drop the second one.

Regarding this code:

Code: Select all

%mehr Platz zwischen Überschrift und Tabelle
\newcommand{\@ldtable}{}
\let\@ldtable\table
\renewcommand{\table}{ %
                 \setlength{\@tempdima}{\abovecaptionskip} %
                 \setlength{\abovecaptionskip}{\belowcaptionskip} %
                 \setlength{\belowcaptionskip}{\@tempdima} %
                 \@ldtable}
What document class are you using? If you are using one of the KOMA-Script document classes (or are using the caption or subfig package), the above code will have the opposite effect as desired.
effeksys
Posts: 3
Joined: Wed Jul 06, 2011 7:53 pm

Hyperlink problem

Post by effeksys »

Thanks for the hint 5gon12eder, but isn't unfortunately the problem.

Inserted Hyperlinks look are follows:
Bildschirmfoto 2011-07-07 um 09.49.15.png
The associated Latex-Code:

Code: Select all

\href{http://www.bildung-lsa.de}{http://www.bildung-lsa.de}
Btw: the hyperlinks are in a table/cell and i use Lyx 2.0.0 on Mac OS X.

Code: Select all

\begin{tabular}{|c|c|c|}
\hline 
Lfd.-Nr.: & Bildungsserver in: & URL des Webauftritts:\tabularnewline
\hline 
\hline 
1 & Baden-Württemberg & \href{http://www.schule-bw.de}{http://www.schule-bw.de}\tabularnewline
The template uses "scrreprt" as document class.
5gon12eder
Posts: 126
Joined: Sun Feb 13, 2011 8:36 pm

Hyperlink problem

Post by 5gon12eder »

The last piece of code you've posted is okay. (It compiles fine on my system.) I can only advise you to make a minimal working example that reproduces your error. Most likely, while doing so, you will find the problem yourself. In case you don't, upload your minimal example here and we'll see how to fix it.

See here for a guide to create a minimal example: http://minimalbeispiel.de/mini-en.html
I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian).
Post Reply