3

I am about to start writing my thesis and decided to finally learn sth other than Word. Realized that LyX has shorter learning curve than plain LaTeX so I decided to give it a shot. It is great so far and have realized how I should have done this long time ago. A bunch of things that started to cause headaches for me (mainly when writing articles) have just disappeared. My problems started when I realized that I do have LaTeX rules for writing a thesis at my university, but there is no easy way (for me at least) to implement it in LyX. After reading a couple of similarly themed threads here, I came to the conclusion that the LaTeX files provided by my university are not templates or classes or layouts, instead, they are "just" plain .tex files. Of course, I can open them in, let's say, TexWorks, but after a whole day of trying, I can't figure out how to import them into the LyX environment. Is there any hint on how I should do it, i.e. how I can use the LaTeX provided rules for writing a thesis in LyX?

The .zip file containing all the "LaTeX related" materials from my university is here: https://www.fer.unizg.hr/_download/repository/latex_template%5B1%5D.zip

Obviously, I don't need to emphasize that I am a total newbie when it comes to LaTeX.

Sorry for a maybe stupid question and thanks for any help!

  • 2
    Welcome to TeX.SX! main.tex in your .zip file is your 'template' (And personally I doubt that one can 'learn' LaTeX by using LyX, Texmaker, TeXstudio etc.) – user31729 Oct 15 '15 at 13:06
  • 3
    First, that's a pretty unpleasant looking set of files. Second, I'd suggest going through the included PDF looking for items you'll need to change (department, supervisor, year, etc.). Find those items in main.tex or other included files and change them. Then I'd look at the files in Stephen Eglen's A short example of how to use LaTeX in scientific reports for the basics of sectioning, inserting tables and figures, etc. As @ChristianHupfer hinted at, I don't think there's any benefit to adapting the TeX files into LyX for a new user. – Mike Renfro Oct 15 '15 at 13:38
  • Hi, thanks for the fast response. So, basically, you are suggesting that I should forget about trying to do the thesis in LyX and instead just go with writing it directly using LaTeX? I was actually thinking whether to do it like that (since I started completely from scratch) but LyX did seem more user friendly, when writing formulas and stuff. – tom555 Oct 15 '15 at 16:29
  • Yes, I'm suggesting working in LaTeX. Visual editors for formulas can lead to users finding the closest visual equivalent to a symbol or operator instead of finding the right symbol from documentation (Voss' Mathmode, Gratzer's Math Into LaTeX, etc.). However, there are visual equation editors for LaTeX, too, at least inside web browsers, and some for local applications. – Mike Renfro Oct 16 '15 at 11:24
4

My suggestion is writing it directly using LaTeX files.

Nonetheless, said that, unlike many thesis templates, in this case main.tex do not use a custom document class but the standard book that is already supported by Lyx without any special configuration.

So you can File > Import > LaTeX (plain) ... > select main.tex. This will make main.lyx as well as lyx versions of all the subdocuments.

However, the imported file will have some problems:

1. Conflicts between the imported preamble and own LyX settings for the document. The solution is remove from Document > Settings... > LaTeX Preamble what could be fixed in other sections of Document > Settings....

For example, in the original main.tex file, this lines:

\documentclass[12pt,oneside, a4paper]{book}
\usepackage[croatian]{babel}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}

Will be traduced by LyX in this LaTeX source:

\documentclass[12pt,oneside,croatian]{book}
\usepackage[croatian]{babel}
\usepackage[a4paper]{geometry}

Beside setting defaults margins in geometry, this is wrong mainly because the croatian option cannot be passed two times to the babel package. But you can remove both packages from the preamble and configure them through the LyX interface to produce this:

\documentclass[12pt,oneside,croatian]{book}
\usepackage{babel}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}

That is essentially the same that the original .tex file.

2. Many LaTeX code remain as Evil Red Text boxes (aka ERT boxes or TeX Code boxes that you can insert with Ctrl+L ).

%%%%%%%%%%%%%%%%%%%... \frontmatter

Generally the ERT boxes are not harmful (the file is still compilable) but annoying. In this case, many of these ERT are LaTeX comments that you remove safely or convert in yellow notes. Others are commands as \tableofcontents that you can replace easily by Lyx objects as Insert > List/ToC > Table of contents and some others could be LaTeX code that is better maintain "as is" since you cannot (or you do not know) replicate through the GUI of LyX (for example, the titlepage environment). If unsure, left the ERT boxes!

3. Imported images are too big on the screen. This is a minor problem easy to solve: Right-click on the image Settings... > LateX and LyX options > Scale on the screen (%) > try with a 1-10%. The image size on the PDF is not modified by this setting.

4. Conflicts inherited from converted sub documents. The conversion of the main file is not too hard but debug compilations errors due (for example) to atabularx environment infested with dozens of ERT boxes in a included subdocument will be a nightmare even for experts. Simply avoid these conflicting example subdocuments until you have a compilable main file. Then start including simple subdocuments with only some text. Remember that LyX cannot produce any type of LaTeX code, only the most common commands and environments, but you always insert unknow code for LyX as long as you use the ERT boxes, and when needed, packages/definitions in the preamble so LaTeX can understand these ERT boxes.

So, after some cleaning, your main.lyx could be some like this:

mwe

  • Hi Fran, thanks for the elaborate reply. The first thing I did was to try to import the main.tex file in LyX. Unfortunately, it gives me the "Cannot convert file" error saying >" An error occurred while running: C:\LaTeX\LyX\bin\tex2lyx -f "main.tex" "main.lyx" ". I couldn't resolve it but assumed LyX just can't import such a "complex" file. So I was maybe thinking of doing the document formatting using the rules from the .lyx file. Is there any way I can import the file to LyX? If not, I guess i will try manually... – tom555 Oct 15 '15 at 22:41
  • @tom555 Have you a working tex2lyx at the system prompt? I was able to convert it in Lyx 2.0.8.1 from Linux Mint with "only" the commented problems, and without some subdocument it was compilable. – Fran Oct 16 '15 at 4:07
  • @tom555 May be easier could be start a empty book in Lyx, set margins, idiom, paste in the "LateX preamble" settings the LaTeX preamble ---forgive the redundancy :) --- without babel and geometry, and then paste the code of the 3 cover pages as an ERT box. The rest (ToC, includes, etc.) could be made easily using LyX menus. – Fran Oct 16 '15 at 5:52
  • Thank you for all the suggestions. After some tweaking/playing/learning, I managed to end up with a "sort of" hybrid between LyX and plain LaTeX. I have made a main .lyx file in which I've incorporated my thesis rules into a preamble and am including all the title pages (and so on) written directly in LaTaX (it seems much easier to accomplish what I want directly). But my plan is to write all the chapters in LyX since it seems easier to write equations and tables in it. Al least for now. Thanks again for all the help! – tom555 Oct 19 '15 at 8:39
  • btw, importing the .tex file directly in LyX didn't work, but calling tex2lyx from prompt worked, with all the mentioned warnings... Thanks for that as well! – tom555 Oct 19 '15 at 8:42
2

There's nothing really special about that TeX file, just a lot of junk. I'd start with an empty LyX document of the book class and set things to look as the template pdf when you add your own stuff. Then if something is missing just add the relevant code from the main file. I'm almost sure everything can be done without any code in TeX insets. Go through the code in main.tex and set the options you can find in LyX document settings. Sretno! (Save the following code as a LyX file and use it as a template)

    #LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass extbook
\begin_preamble
\makeatletter
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
  \addpenalty{-\@highpenalty}%
  \vskip 1.0em \@plus\p@
  \setlength\@tempdima{1.5em}%
  \begingroup
  \parindent \z@ \rightskip \@pnumwidth
  \parfillskip -\@pnumwidth
  \leavevmode \bfseries
  \advance\leftskip\@tempdima
  \hskip -\leftskip
  #1\nobreak\normalfont\leaders\hbox{$\m@th
    \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
    mu$}\hfill\nobreak\hb@xt@\@pnumwidth{\hss #2}\par
  \penalty\@highpenalty
  \endgroup
  \fi}
\makeatother
\end_preamble
\use_default_options true
\maintain_unincluded_children false
\language croatian
\language_package default
\inputencoding utf8
\fontencoding global
\font_roman ae
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family rmdefault
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize 12
\spacing onehalf
\use_hyperref true
\pdf_bookmarks true
\pdf_bookmarksnumbered false
\pdf_bookmarksopen false
\pdf_bookmarksopenlevel 1
\pdf_breaklinks false
\pdf_pdfborder true
\pdf_colorlinks true
\pdf_backref false
\pdf_pdfusetitle true
\papersize a4paper
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine natbib
\cite_engine_type numerical
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 2.5cm
\topmargin 2.5cm
\rightmargin 2.5cm
\bottommargin 2.5cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language polish
\papercolumns 1
\papersides 1
\paperpagestyle fancy
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
begin{titlepage}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\align center
\begin_inset Box Boxed
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "3.5cm"
special "none"
height "3.5cm"
height_special "none"
status open

\begin_layout Plain Layout

\end_layout

\end_inset


\end_layout

\begin_layout Standard
\align center

\family sans
\size large
FAKULTET ELEKTROTEHNIKE I RAČUNARSTVA
\family default
\size default

\begin_inset VSpace 3cm
\end_inset


\end_layout

\begin_layout Standard
\align center

\family sans
\size large
Ime Prezime
\end_layout

\begin_layout Standard
\align center
\begin_inset VSpace 2cm
\end_inset


\end_layout

\begin_layout Standard
\align center

\family sans
\series bold
\size largest
NASLOV RADA
\end_layout

\begin_layout Standard
\align center
\begin_inset VSpace 2cm
\end_inset


\end_layout

\begin_layout Standard
\align center

\family sans
\size large
DOKTORSKI RAD
\end_layout

\begin_layout Standard
\align center
\begin_inset VSpace 4cm
\end_inset


\end_layout

\begin_layout Standard
\align center

\family sans
\size large
Mentor: Prof.
 dr.
 sc Ime Prezime
\end_layout

\begin_layout Standard
\align center
\begin_inset VSpace vfill
\end_inset


\end_layout

\begin_layout Standard
\align center

\family sans
\size large
Zagreb, 2016.
\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
end{titlepage}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
pagestyle{empty}
\end_layout

\end_inset


\end_layout

\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents

\end_inset


\end_layout

\begin_layout Standard
\begin_inset Newpage cleardoublepage
\end_inset


\end_layout

\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
pagestyle{fancyplain}
\end_layout

\end_inset


\end_layout

\begin_layout Chapter
Uvod
\end_layout

\begin_layout Standard
U ovom poglavlju prikazane su neke od funkcija koje se mogu\SpecialChar \ldots{}

\end_layout

\end_body
\end_document

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.