I'm writing my master thesis with latex. I'm using ubuntu as an OS and Texstudio as an editor. The problem is that in some pages in my document there is line breaks that i didn't write. Also after some section title there is more space then in the previous section titles. I ll add screenshots to show the problem.

Now what confuses me more is, when I used latex at work, I didn't get this weird behavior. I'm using git to push the repository to github so I can also continue writing at home. I noticed that at work all works good when I compile my code to pdf. However, at home on my personal computer, I get those weird line breaks and space issues when I compile and get a pdf.

Does anyone had this before? it is because of the ubuntu version or latex version maybe? I tried using different editors first since I thought maybe it is because of texstudio but that was not the case.

here I added screenshots to show what i mean. In the first picture there is additional line breaks always between the sentences or after a title. What I want is that it looks like the second picture. I don't know why this is happening, at work this didn't happen and I'm not using some fancy packages or something. I'm basically writing standard stuff. The only command I'm using is \noindent to remove the first indentation. I hope someone can help me here since now my thesis looks awful and I must submit it this month.

enter image description here enter image description here

this is the setup file i'm using, where I download all package and set settings:

%       package includes
    % font encoding is set up for pdflatex, for other environments see
    % http://tex.stackexchange.com/questions/44694/fontenc-vs-inputenc
    \usepackage[T1]{fontenc}  % 8-bit fonts, improves handling of hyphenations
    \usepackage[dvipsnames]{xcolor}  % more colors
    % provides `old' commands for table of contents. Eases the ability to switch
    % between book and scrbook
   \usepackage{color, colortbl}
    % ------------------- layout, default -------------------
    % adjust the style of float's captions, separated from text to improve readabilty
    \usepackage[labelfont=bf, labelsep=colon, format=hang, textfont=singlespacing]{caption}
    \usepackage{chngcntr}  % continuous numbering of figures/tables over chapters
    % Uncomment the following line if you switch from scrbook to book
    % and comment the setkomafont line
    %\usepackage{titlesec}  % remove "Chapter" from the chapter title

    \usepackage{setspace}  % Line spacing
    % \doublespacing  % uncomment for double spacing, e.g. for annotations in correction

    % ------------------- functional, default-------------------
    \usepackage{array}  % custom format per column in table - needed on the title page
    \usepackage{graphicx}  % include graphics
    \usepackage{subfig}  % divide figure, e.g. 1(a), 1(b)...
    \usepackage{amsmath}  % |
    \usepackage{amsthm}   % | math, bmatrix etc
    \usepackage{amsfonts} % |
    \usepackage{calc}  % calculate within LaTeX
                pdfborder={0 0 0},backref=false,colorlinks=false]{hyperref}

    % You might not need the following packages, I only included them as they
    % are needed for the example floats
    % ------------------- functional, custom -------------------
    \usepackage{bm}  % bold greek variables (boldmath)
    \usetikzlibrary{positioning}  % use: above left of, etc

    % Improves general appearance of the text
    \usepackage[protrusion=true,expansion=true, kerning]{microtype}

%---------------- equations packages --------------------------------------
    \usepackage[thinc]{esdiff} % for derivatives

%---------------- appendix and json --------------------------------------
    %\usepackage{bera}% optional: just to have a nice mono-spaced font
    \usepackage{booktabs} % for using pandas tables
%---------------------------- for the random forest --------------------
\tikzset{marrow/.style={midway,red,sloped,fill, minimum height=3cm, single arrow, single arrow
        head extend=.5cm, single arrow head indent=.10cm,xscale=0.3,yscale=0.15,
        allow upside down}}

%       (re)new commands / settings
    % ----------------- referencing ----------------

    % ------------------- colors -------------------
    \definecolor{darkgreen}{rgb}{0.0, 0.5, 0.0}
    % Colors of the Albert Ludwigs University as in
    % https://www.zuv.uni-freiburg.de/service/cd/cd-manual/farbwelt
    \definecolor{UniBlue}{RGB}{0, 74, 153}
    \definecolor{UniRed}{RGB}{193, 0, 42}
    \definecolor{UniGrey}{RGB}{154, 155, 156}

    % ------------------- layout -------------------
    % prevents floating objects from being placed ahead of their section

    % ------------------- marker commands -------------------
    % ToDo command
    \newcommand{\todo}[1]{\textbf{\textcolor{red}{(TODO: #1)}}}
    \newcommand{\extend}[1]{\textbf{\textcolor{darkgreen}{(EXTEND: #1)}}}
    % Lighter color to note down quick drafts
    \newcommand{\draft}[1]{\textbf{\textcolor{NavyBlue}{(DRAFT: #1)}}}

    % ------------------- math formatting commands -------------------
    % define vectors to be bold instead of using an arrow
    % tag equation with name

    % ------------------- pdf settings -------------------
    \hypersetup{pdftitle={The great title!},
                pdfauthor={FirstName LastName},
                pdfsubject={Undergraduate thesis at the Albert Ludwig University of Freiburg},
                pdfkeywords={deep learning, awesome algorithm,  undergraduate thesis},
                pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false}

    % You might not need the following commands, I only included them as they
    % are needed for the example floats

    % ------------------- Tikz styles -------------------
    \tikzset{>=latex}  % arrow style

    % ------------------- algorithm ---------------------
    % Command to align comments in algorithm
    % define a foreach command in algorithms
    \algdef{S}[FOR]{ForEach}[1]{\algorithmicforeach\ #1\ \algorithmicdo}

and then I just write like normal I don't use anything special, here is an example

\subsection{Random Forests} \label{sub:random_forest}
blabla Although the decision tree algorithm is very powerful for solving regression problems, it suffers mainly from the high variance or overfitting problem discussed in \ref{sub:overfitting} ~\cite{review_decision_tree}. To tackle this issue in general, researchers developed some higher level methods called \emph{ensembles}. 

\noindent As in real life, sometimes considering many different opinions about something is better than sticking around with only one opinion, this is basically the idea behind the ensemble methods, they combine predictions from multiple machine learning algorithms in order to deliver more accurate predictions than an individual model ~\cite{ensembles}. 
  • Without code to show the problem how should we know? All we know is that it is not related to Linux, TeXstudio or Ubuntu. – daleif Apr 2 at 13:50
  • My guess you have something that is moved to the next page and LaTeX is trying to maintain equal height of the text (default in twosided setups), but as you show no code, that is only a guess. – daleif Apr 2 at 13:51
  • LaTeX is trying to make the pages all the same height -- that is why it inserts extra vertical space between paragraphs. In a proper article or book the pages look better if they are all the same height. There are various ways to turn off the behaviour but without an example of your code it is hard to know what to recommend – Thruston Apr 2 at 13:52
  • 1
    Note that if this is part of that template, it is really messy. You need to provide something that lets others reproduce your problem, otherwise we cannot help. Often a good idea is to make a separate copy of your project, then on that copy start removing stuff until you have something minimal that shows the problem. This is also a good debugging technique where users often learn what the problem actually is. – daleif Apr 2 at 14:00
  • 1
    Do you get what I mean? Is the latex installation the same? The class and package versions. – daleif Apr 2 at 14:25

From looking at the code offline, this is mainly due to using [H] on floats.

It was probably shear luck that these big holes did not appear on the work PC.

General advise don't use [H], it has its uses in very specialist documents. A thesis is not one of these.

| improve this answer | |
  • I noticed something. When I use [htbp] instead of [H] it solves my problem with the indentation (line breaks) but the image is now not in the same place where I want it to be. With [H] the image is exactly under the sentence where I want but using [htbp] changed its position and I dont want that to happen. Do you know how can I solve this? – basilisk Apr 2 at 18:26
  • 1
    @basilisk you need to leave the requirement of having an image right here, you don't see that in any published publications either. This is what we have the reference system for. If there is room for it it will be "here", if not it will be moved as it should. – daleif Apr 2 at 18:30
  • alright so you suggest to leave it as it is and use the ref\ to reference every images regarding of where it is in the section? – basilisk Apr 2 at 18:39
  • 1
    @basilisk exactly, that is the correct way. In the end you can adjust a few things about the placement, but you should finish your thesis first. The insistence on [H] is very common among new users. Just make sure you use at least htp – daleif Apr 2 at 18:42
  • 1
    @basilisk due to images often being too large to fit right here and since we don't want large white gaps in your texts we want the images to go here if there is space, else "here about", that is exactly what a non-H float does – daleif Apr 2 at 18:49

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.