LyXProblem: Import LaTeX to LyX (a title page with graphics)

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
pooz
Posts: 65
Joined: Sat Apr 11, 2009 10:47 am

Problem: Import LaTeX to LyX (a title page with graphics)

Post by pooz »

Hello,

I have problems, when importing a LaTeX doc into LyX.

The LaTeX Code is correct and will be compiled in TeXShop (a main file calls the "title.tex" File)
But when I import this "title.tex"-file or even only the code (by CMD-L), Lyx wont compile it.

When inserting the complete code via "insert/Tex Code (CMD-L) or when trying to import Latex-File: Lyx gives this error:

Code: Select all

\href
          {http://www.google.de}  { \includegraphics[width = 2.8cm]{figures/...
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
The Code is:

Code: Select all

\begin{titlepage}
\label{sec:title}

%\enlargethispage{\voff}
\large 
\begin{center}

\href{http://www.google.de} 
{
\includegraphics[width = 2.8cm]{figures/center_logo.pdf} 
}


\vspace{1.5cm}

% Titel
\begin{minipage}{1.1\linewidth}
{\centering\Huge\bf My long Title with technical terms}%\par} 
% \par ist nštig fŸr korrekten Zeilenabstand im Titel
\end{minipage}

\large 


\vspace{.1cm}
{\huge{\bf \it Title 2} %\\[1cm]
}

\vspace{.1cm}
{
\Large von \\[.5cm] 
{\bf \LARGE \huge Author}\\[1.5cm]
}

\end{center}


\vfill
%\vspace{1.2cm}
\begin{minipage}[c]{7.5cm}
	\href{http://www.wikipedia.org} 
	{
		\includegraphics[width = 7cm]{figures/mini_left_logo.pdf} 
	}
\end{minipage}
\begin{minipage}[c]{7cm}
	\begin{tabular}{ll}
		Beginn:&  2008\\
		Ende:& 2009\\
		Nr.:& \\
	\end{tabular}
\end{minipage}


\vspace{2cm}
\end{titlepage}

I would be thankful for any help
greetings

Recommended reading 2024:

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

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

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Problem: Import LaTeX to LyX (a title page with graphics)

Post by meho_r »

Your code is not compilable, it's missing a lot of elements (no \documentclass, no \begin{document} etc.). Please, post fully compilable Minimum Working Example.
pooz
Posts: 65
Joined: Sat Apr 11, 2009 10:47 am

Re: Problem: Import LaTeX to LyX (a title page with graphics)

Post by pooz »

My Code is placed in a file called "title.tex" and this file again will be called by a main template file called "template.tex". But the main file is very big, because it includes a lot of other files beside "title.tex" like "chapter1.tex" etc... and has a big preamble/header stuff.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Problem: Import LaTeX to LyX (a title page with graphics)

Post by meho_r »

And you expect that people here guess what documentclass you're using, which packages you're using etc.? You haven't provide the most basic infos. Of course you don't have to post your whole document, but you really have to post compilable example. Don't expect help if you're not obeying fundamental rules (Minimum Working Example being one of them).

Here's a doc which works when imported in LyX. You'll have to correct paths for included graphics and remove part above \begin{document} (including \begin{document} and \end{document} lines):

Code: Select all

\documentclass{book}
\usepackage{graphicx}
\usepackage{hyperref}

\begin{document}
\begin{titlepage}
\label{sec:title}

%\enlargethispage{\voff}
\large 

\begin{center}

\href{http://www.google.de} 
{%
\includegraphics[width = 2.8cm]{center_logo.pdf}%
}

\vspace{1.5cm}

% Titel
\begin{minipage}{1.1\linewidth}
{\centering\Huge\bf My long Title with technical terms}%\par} 
% \par ist nštig fŸr korrekten Zeilenabstand im Titel
\end{minipage}

\large 

\vspace{.1cm}
{\huge{\bf \it Title 2} %\\[1cm]
}

\vspace{.1cm}
{
\Large von \\[.5cm] 
{\bf \LARGE \huge Author}\\[1.5cm]
}

\end{center}

\vfill
%\vspace{1.2cm}
\begin{minipage}[c]{7.5cm}
   \href{http://www.wikipedia.org} 
   {%
      \includegraphics[width = 7cm]{mini_left_logo.pdf}% 
   }
\end{minipage}
\begin{minipage}[c]{7cm}
   \begin{tabular}{ll}
      Beginn:&  2008\\
      Ende:& 2009\\
      Nr.:& \\
   \end{tabular}
\end{minipage}

\vspace{2cm}

\end{titlepage}

\end{document}
Take notice of the packages in the preamble which are needed to compile this document correctly, so make sure you'll have them in your master document's preamble (especially graphicx package which is needed for \includegraphic command to work).
pooz
Posts: 65
Joined: Sat Apr 11, 2009 10:47 am

Problem: Import LaTeX to LyX (a title page with graphics)

Post by pooz »

It wasn´t my intention, to not provide an information. It is just, that I am a LaTeX noob and have only very few knowledge about it. Thats why I am using LyX.

Now, I deleted some comments and "chapter-includes" to build a minimal example.
here we go for the "template.tex"

Code: Select all

\NeedsTeXFormat{LaTeX2e}


\documentclass[a4paper, twoside, 11pt]{report}

\newif\ifmakeindex
\makeindextrue % generate index
%\makeindexfalse % don't generate index

\ifmakeindex
\usepackage{makeidx}

% Stichwortverzeichnis erstellen
\makeindex
\fi

\newif\ifenglish
\englishfalse  % german document

\usepackage[margin=1cm,format=hang,font=small,labelfont=bf,textfont=sl]{caption}

\usepackage{subfigure}

\usepackage[ngerman]{babel}


\usepackage[latin1]{inputenc}
% Unterstuetzen von deutschen Umlauten

\usepackage{t1enc}

\usepackage{courier} 
\usepackage{bibgerm}



\usepackage{cite}


\usepackage{fancyheadings}

\usepackage{float}\usepackage{verbatim}

\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage{array}


\usepackage{ifthen}
\usepackage{longtable}


\usepackage{varioref}
% Kommando \vref verweist mit Seitenzahl

\usepackage{readfile}
% ASCII-File einbinden mit
% \readit{fftdb.m}{\tt} 
% 2. Argument (\tt) gibt zu benutzende Schriftart an 
\usepackage{shapepar}
\usepackage{setspace}
\usepackage{colortbl}
\usepackage{color}
\usepackage{xcolor} 

\usepackage{listings}

\lstloadlanguages{}

\lstloadlanguages{C,C++,Java,Matlab,HTML,TeX,XML}



\lstset{
				frame=lines, %Umrandung (single|none|shadowbox|lines|bottomline|topline|leftline)
				framerule=1pt, %Rahmenbreite
				tabsize=4, %Anzahl der Zeichen für ein TAB
				backgroundcolor=\color{lightgray}, %Hintergrundfarbe
				emph={}, %hebt die angegebenen Wörter hervor
				emphstyle=\underbar, %unterstreicht hervorgehobene Wörter
				columns=fixed, %Zeichenabstand (fixed | flexible | fullflexible)
				lineskip=0pt, %Zeilenabstand
				basicstyle=\ttfamily,%\ttfamily,
				identifierstyle=\color{black},
        commentstyle=\color{darkgreen},
        stringstyle=\color{viola},
        keywordstyle=\color{darkblue},
				ndkeywordstyle=\color{black},
				showspaces=false,
				showtabs=false,
				numbers=none, %Zeilennummern (none|left|right)
				%numbertype=\ttfamily,
				breaklines=true,
        captionpos=b,
        extendedchars=false
}


\def\boxes{yes}

\newif\ifpdfout
\ifx\pdfoutput\undefined
   \pdfoutfalse
\else
   \pdfoutput=1
   \pdfouttrue
\fi

\ifpdfout % compiling with pdflatex
   \usepackage[pdftex]{graphicx}
   \DeclareGraphicsExtensions{.pdf, .png, .jpg}
   \usepackage[pdftex,
	bookmarks,
	%colorlinks=false, % instead of colors, now boxes are used for links
	colorlinks=true,
	urlcolor=black, %blue,
	linkcolor=black, %red, %normal internal links
	citecolor=black, %green, %citation links
	%pagebackref, %link from references back to page of citation
	linktocpage, 
	% im Inhaltsverzeichnis Link auf Seitenzahl (sonst Probleme bei langen Zeilen)
	%breaklinks = true, % für Links länger als 1 Zeile
	%hypertexnames = false,  % für Links zu Figures?
	bookmarksopen, %open all bookmark folders
	bookmarksnumbered, %use section numbers with bookmarks
    pdfpagemode=UseOutlines, %show bookmarks
	% http://www.tex.ac.uk/cgi-bin/texfaq2html?label=pdfpagelabels
	plainpages=false, % eigene Seitenanker für römische/arabische Seitenzahlen
	pdfpagelabels, % im Abode Reader Seitenzahl als z.B. "iii (3 von 20)" anzeigen
%	pdfstartview=FitH
	pdfstartview=FitV
	]{hyperref}
    \pdfadjustspacing=1                %%% force LaTeX-like character spacing
    \pdfcompresslevel=9
	\pdfcatalog{                 
	% Catalog dictionary of PDF output 
	} %end of \pdfcatalog
\else % compiling with latex
  \usepackage[dvips]{graphicx}
%  \usepackage{color}
  \DeclareGraphicsExtensions{.eps}
  \usepackage[
    dvips,

	bookmarks,
  	colorlinks=false,  % for final paper without colors
%  	colorlinks=true,
	linktocpage, 	

	bookmarksopen, %open all bookmark folders
	bookmarksnumbered, %use section numbers with bookmarks
    pdfpagemode=UseOutlines, %show bookmarks
	pdfstartview=FitV
   ]{hyperref}
  % hyperrefs are active is the pdf file after conversion
  \hypersetup{
	pdfcreator  = {LaTeX with hyperref package},
	pdfproducer = {dvips + ps2pdf}
  }
\fi

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

\input{macros.tex}

 \mathchardef\CommaOrdinary="013B
 \mathchardef\CommaPunct   ="613B
 \mathcode`,="8000   % , im Math-Mode aktiv ("8000) machen
 {\catcode`\,=\active
  \gdef ,{\obeyspaces\futurelet\next\CommaCheck}}
 \def\CommaCheck{\if\space\next\CommaPunct\else\CommaOrdinary\fi}

\input{layout.tex}

% Umdefinition der Bezeichner
\addto\captionsngerman{% Eigene Bezeichner: Abb. -> Bild, Tab.-> Tabelle
	\renewcommand{\figurename}{Bild}%
	\renewcommand{\tablename}{Tabelle}%
	\renewcommand{\lstlistlistingname}{Quellcodeverzeichnis} % default: "Listings"
	\renewcommand{\lstlistingname}{Quellcode} % default: "Listing"
}
\addto\captionsenglish{% 
	\renewcommand{\lstlistlistingname}{List of Sourcecodes} % default: "Listings"
	\renewcommand{\lstlistingname}{Sourcecode} % default: "Listing"
}



\begin{document}
\include{colors} 
\pagenumbering{roman} 

\include{title}


\end{document}
Thanks for your code:
But it doesn´t work when importing this to LyX after deleting the lines you mentioned and saving the code to a fresh file i.e. "test.tex". The error LyX throws is the same as in my opening-post.

It seems, that LyX has problems with hyperlinks behind an image, hasn´t it?
- graphicx is used in this way

Code: Select all

\usepackage[dvips]{graphicx}
% (...)
\usepackage[pdftex]{graphicx}
Thanks
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Problem: Import LaTeX to LyX (a title page with graphics)

Post by meho_r »

Did you solve the problem? I tried your new code, but still cannot compile it. Can you provide package readfile.sty? macrox.tex and layout.tex are missing (you shouldn't include any external material in MWE, or at least provide them). Without these I can't get any output.
pooz
Posts: 65
Joined: Sat Apr 11, 2009 10:47 am

Problem: Import LaTeX to LyX (a title page with graphics)

Post by pooz »

Hi,

unfortunately I did not get it working. I am still on the state of my last post.

readfile.sty

Code: Select all

\def\readit#1#2{\begingroup\@endpefalse
      \trivlist \item[]\if@minipage\else\vskip\parskip\fi
      \leftskip\@totalleftmargin\rightskip\z@
      \parindent\z@\parfillskip\@flushglue\parskip\z@
      \@tempswafalse \def\par{\if@tempswa\hbox{}\fi\@tempswatrue\@@par}
      \obeylines #2 \catcode``=13 \@noligs \let\do\@makeother \dospecials 
      \frenchspacing\@vobeyspaces \@myxverbatim{#1}
      \endgroup}

\begingroup \catcode `|=0 \catcode `[= 1
\catcode`]=2 \catcode `\{=12 \catcode `\}=12                       
\catcode`\\=12 |gdef|@myxverbatim#1[|input #1 ] 
|endgroup
- macrox.tex and layout.tex are in my folder, whith all other files.
Post Reply