Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have written a LaTeX math document with lyx (using document ams class), but now my teacher sent me some LaTeX code which should make the style as he wants it.

I tried a few options to insert the LaTeX code, none worked:

1) add (through lyx) the LaTeX code itself - This didn't work, since there were double definitions, both in the lyx default generated LaTeX code, and the LaTeX code I inserted.

2) through MiKTeX TeXworks- I exported my lyx document to LaTeX, and tried to change all the definitions before \begin{document} to the ones my teacher sent me - This didn't compile, complained about missing definitions, xtra, xtra.

3) through bakoma - i tried opening my exported lyx code, and then inserting the code my teacher sent me at the beginning - This actually worked, but the bibliography and figure placement got ruined - the figures were put at the end, and the bibliography disappeared.

Anyone has any ideas ? What should be the right way to tackle my problem? Attached is the code my teacher sent me

%&latex
\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{latexsym}
\usepackage{epsfig}
\usepackage{hyperref}
%\usepackage[normalem]{ulem} %\usepackage[top=80pt,bottom=80pt, left=85pt, right=85pt]{geometry} %\usepackage{setspace} %\onehalfspacing

\setlength{\evensidemargin}{.25in} \setlength{\textwidth}{6in} \setlength{\topmargin}{-0.4in}
\setlength{\textheight}{8.5in}

\newcommand{\handout}[5]{
   \renewcommand{\thepage}{#1-\arabic{page}}
   \noindent
   \begin{center}
   \framebox{
      \vbox{
    \hbox to 5.78in {{\sf Randomized Algorithms}
\hfill \sf #2 }
       \vspace{4mm}
       \hbox to 5.78in { {\Large \hfill #5  \hfill} }
       \vspace{2mm}
       \hbox to 5.78in { {\em #3 \hfill #4} }
      }
   }
   \end{center}
   \vspace*{4mm}
}

\newcommand{\lecture}[4]{\handout{#1}{#2}{Lecture date: #3}{Scribe: #4}{Lecture #1}}


\textwidth=6in \oddsidemargin=0.25in \evensidemargin=0.25in \topmargin=-0.1in \footskip=0.8in
\parindent=0.0cm
\parskip=0.3cm
\textheight=8.00in \setcounter{tocdepth} {3} \setcounter{secnumdepth} {2} \sloppy


\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{question}[theorem]{Question}
\newtheorem{answer}[theorem]{Answer}
%\newtheorem{exercise}[theorem]{Exercise}
\newtheorem{example}[theorem]{Example}
\newtheorem{algorithm}[theorem]{Algorithm}
%\newtheorem{exercise}[theorem]{Exercise}
\newenvironment{exercise}{\noindent \textbf{Exercise}}{}%[theorem]{Exercise}
\newenvironment{challenge}{\noindent \textbf{Challenge}}{}%[theorem]{Exercise}
\newenvironment{kitbag}{\noindent \textbf{Kitbag Exercise}}{}
\newenvironment{proof}{\noindent \textbf{Proof}}{$\Box$}
\newenvironment{proof-sketch}{\noindent \textbf{Sketch of Proof}}{$\Box$}

\newcommand{\ignore}[1]{}

\renewcommand{\Pr}{{\textup{Pr}}}
\renewcommand{\P}{{\bf P}}
\newcommand{\Px}{\mathop{\bf P\/}}
\newcommand{\E}{{\bf E}}
\newcommand{\Ex}{\mathop{\bf E\/}}

\newcommand{\Var}{{\bf Var}}
\newcommand{\Cov}{{\bf Cov}}
\newcommand{\Varx}{\mathop{\bf Var\/}}

\newcommand{\bits}{\{-1,1\}}

\newcommand{\nsmaja}{\textstyle{\frac{2}{\pi}} \arcsin \rho}

\newcommand{\Inf}{\mathrm{Inf}}
\newcommand{\I}{\mathrm{I}}
\newcommand{\J}{\mathrm{J}}

\newcommand{\eps}{\epsilon}
\newcommand{\lam}{\lambda}
\newcommand{\N}{\mathbb N}
\newcommand{\R}{\mathbb R}
\newcommand{\Z}{\mathbb Z}
\newcommand{\C}{\mathbb C}
\newcommand{\CalE}{{\mathcal{E}}}

\newcommand{\CalU}{{\mathcal{U}}}
\newcommand{\F}{{\mathcal{F}}}
\newcommand{\CalC}{{\mathcal{C}}}
\newcommand{\CalM}{{\mathcal{M}}}
\newcommand{\CalR}{{\mathcal{R}}}
\newcommand{\CalS}{{\mathcal{S}}}
\newcommand{\CalV}{{\mathcal{V}}}
\newcommand{\CalX}{{\boldsymbol{\mathcal{X}}}}
\newcommand{\CalG}{{\boldsymbol{\mathcal{G}}}}
\newcommand{\CalY}{{\boldsymbol{\mathcal{Y}}}}
\newcommand{\CalZ}{{\boldsymbol{\mathcal{Z}}}}
\newcommand{\CalF}{{\mathcal{Z}}}
\newcommand{\boldG}{{\boldsymbol G}}
\newcommand{\boldQ}{{\boldsymbol Q}}
\newcommand{\boldR}{{\boldsymbol R}}
\newcommand{\boldS}{{\boldsymbol S}}
\newcommand{\boldX}{{\boldsymbol X}}
\newcommand{\bfX}{{\boldsymbol X}}
\newcommand{\boldB}{{\boldsymbol B}}
\newcommand{\boldY}{{\boldsymbol Y}}
\newcommand{\boldZ}{{\boldsymbol Z}}
\newcommand{\boldV}{{\boldsymbol V}}
\newcommand{\boldsigma}{{\boldsymbol \sigma}}
\newcommand{\boldupsilon}{{\boldsymbol \upsilon}}
\newcommand{\hone}{{\boldsymbol{H1}}}
\newcommand{\htwo}{\boldsymbol{H2}}
\newcommand{\hthree}{\boldsymbol{H3}}
\newcommand{\hfour}{\boldsymbol{H4}}
\newcommand{\poly}{\boldsymbol{poly}}


\newcommand{\sgn}{\mathrm{sgn}}
\newcommand{\Maj}{\mathrm{Maj}}
\newcommand{\Thr}{\mathrm{Thr}}
\newcommand{\littlesum}{{\textstyle \sum}}

\newcommand{\half}{{\textstyle \frac12}}

\newcommand{\Stab}{\mathbb{S}}
\newcommand{\StabThr}[2]{\Gamma_{#1}(#2)}
\newcommand{\TestFcn}{\Psi}

\renewcommand{\phi}{\varphi}
\def \la      {\langle}
\def \ra      {\rangle}

\newcommand{\x}{\mathbf{x}}
\renewcommand{\o}{\mbox{o}}
\renewcommand{\O}{\mbox{O}}
\newcommand{\h}{\mathbf{H}}
\newcommand{\va}{\mbox{var}}
\renewcommand{\d}{\mbox{d}}
\renewcommand{\C}{\mathcal C}
\newcommand{\qed}{\hfill $\square$}
\begin{document}

\lecture{10}{Moni Naor}{Jan 2, 2011}{Itay Gonshorovitz}



\end{document}
share|improve this question
    
Welcome to tex.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. A tip: if you change 1) to 1. etc. the enumeration is automatically formatted. –  Martin Scharrer Mar 13 '11 at 22:04
2  
It is very complicated to say what's going on if we don't have your teachers code. E.g. if he uses \documentclass in his template it will clash with the one defined in lyx or your exported document. To say something is "ruined" is not a good problem description either. If you want to have a good answer, you have to show some code here. –  Martin H Mar 13 '11 at 22:14
    
Okay, i edited the question and added some code - I was just trying before to be concise so as to not put too much information in the question. Hope now it will be more clear. –  user4165 Mar 13 '11 at 22:56
add comment

3 Answers 3

There's an issue with the Latex file you give: page layout parameters are duplicated, with some, such as topmargin being defined in two different ways.

I've imported this into Lyx without too much bother. Instructions:

  1. Cut and paste an excerpt from the above snippet into the Latex preamble from the DocumentSettings panel, starting from the line \newcommand{\handout}[5]{ and ending before \begin{document}.
  2. On the Fonts tag of the settings panel, set the Base Size to 11pt.
  3. Insert a Tex code block into the document, and paste the body of the Latex file (i.e., inside the begin-end-document environment).

This will then compile.

An issue with this: Lyx will automatically import AMS packages and some others that it knows of, if it sees that you need them, but as I have it, it won't import the other packages defined in the Latex file you gave us. You can paste in the needed \usepackage lines if you need them, but if you use Lyx for writing, you probably will not need these.

share|improve this answer
add comment

Have a look into one of the predefined LyX laout files, they all are saved in a directory named layouts and have the file extensions .layout. In LInux they are saved under /usr/share/lyx/. I don't know what directory it is under Windows. Look for the file slides.layout how such a file has to be defined.

However, it is much more simpler to use directly pdflatex instead of running LyX with creating an own layout file ...

share|improve this answer
    
I doubt that the predefined layouts will include anything useful for the qner. –  Charles Stewart Mar 14 '11 at 9:46
    
@Charles: no, they won't ... –  Herbert Mar 14 '11 at 9:57
add comment

I had a look through you code and with all those definition that your teacher wants you to use it seems a lot easier to write in code rather than lyx (I know this is not an direct answer to your question.)

However, in order to make this code work (with pdflatex) I came up with this

\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{latexsym}   

%\usepackage{epsfig}
\usepackage{graphicx}

\usepackage[normalem]{ulem}

\usepackage[
top=80pt,
bottom=80pt,
left=85pt,
right=85pt,
showframe %show the margin frame
]{geometry}
\usepackage{setspace} \onehalfspacing

%Better use the geometry package above
%to define your margins
%\setlength{\evensidemargin}{.25in} \setlength{\textwidth}{6in}
%\setlength{\topmargin}{-0.4in}
%\setlength{\textheight}{8.5in}

%hyperref should usually be loaded
%as the last package (few exemptions)
\usepackage{hyperref}

\newcommand{\handout}[5]{
   \renewcommand{\thepage}{#1-\arabic{page}}
   \noindent
   \begin{center}
   \framebox{
      \vbox{
    \hbox to 5.78in {{\sf Randomized Algorithms}
\hfill \sf #2 }
       \vspace{4mm}
       \hbox to 5.78in { {\Large \hfill #5  \hfill} }
       \vspace{2mm}
       \hbox to 5.78in { {\em #3 \hfill #4} }
      }
   }
   \end{center}
   \vspace*{4mm}
}

\newcommand{\lecture}[4]{\handout{#1}{#2}{Lecture date: #3}{Scribe:
#4}{Lecture #1}}

%Define the margins with the geometry package above!!!
%This is the second time the margins are defined
% \textwidth=6in \oddsidemargin=0.25in \evensidemargin=0.25in    
%\topmargin=-0.1in
% \footskip=0.8in
% \parindent=0.0cm

%Maybe use oparskip package
% \parskip=0.3cm
% \textheight=8.00in 

\setcounter{tocdepth} {3}
\setcounter{secnumdepth} {2}

%Sure you want to use sloppy??
% \sloppy

\begin{document}

 \lecture{10}{Moni Naor}{Jan 2, 2011}{Itay Gonshorovitz}
\tableofcontents
\section{Some section}

\end{document}

I noticed that the margins are multiply defined but I think using the geometry package is the right way to go here.

Also look up what the \sloppy command does, I think your document will look better without it.

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.