[Tex/LaTex] Another newbie “thesis LaTeX template to LyX” problem

lyxthesis

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.

Best Answer

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