我正在用 latex 写我的硕士论文。我使用 ubuntu 作为操作系统,使用 Texstudio 作为编辑器。问题是,在我的文档中,有些页面有我没有写的换行符。此外,某些章节标题后面的空间比前几个章节标题中的空间要大。我将添加屏幕截图来展示这个问题。
现在让我更困惑的是,当我在工作中使用 latex 时,我没有遇到这种奇怪的行为。我正在使用 git 将存储库推送到 github,这样我也可以继续在家写作。我注意到,当我在工作中将代码编译为 pdf 时,一切都运行良好。然而,在家里用我的个人电脑编译并获取 pdf 时,我遇到了那些奇怪的换行符和空格问题。
有人遇到过这种情况吗?可能是因为 ubuntu 版本或 latex 版本?我首先尝试使用不同的编辑器,因为我认为可能是因为 texstudio,但事实并非如此。
这里我添加了截图来说明我的意思。在第一张图片中,句子之间或标题后总是有额外的换行符。我想要的是它看起来像第二张图片。我不知道为什么会发生这种情况,在工作中这种情况没有发生,而且我没有使用一些花哨的软件包或类似的东西。我基本上是在写标准的东西。我使用的唯一命令是 \noindent 来删除第一个缩进。我希望有人能在这里帮助我,因为现在我的论文看起来很糟糕,我必须在本月提交。
这是我正在使用的安装文件,我在其中下载所有包并设置设置:
%------------------------------------------------------------------------------
% package includes
%------------------------------------------------------------------------------
% font encoding is set up for pdflatex, for other environments see
% http://tex.stackexchange.com/questions/44694/fontenc-vs-inputenc
%\usepackage[table]{xcolor}
\usepackage[T1]{fontenc} % 8-bit fonts, improves handling of hyphenations
\usepackage[utf8x]{inputenc}
\usepackage[dvipsnames]{xcolor} % more colors
% provides `old' commands for table of contents. Eases the ability to switch
% between book and scrbook
\usepackage{scrhack}
\usepackage{pdfpages}
%\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{color, colortbl}
\usepackage{tabularx}
% ------------------- 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
\counterwithout{equation}{chapter}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\usepackage{chngcntr}
\counterwithin{figure}{section}
% Uncomment the following line if you switch from scrbook to book
% and comment the setkomafont line
%\usepackage{titlesec} % remove "Chapter" from the chapter title
%\titleformat{\chapter}[hang]{\bfseries\huge}{\thechapter}{2pc}{\huge}
\setkomafont{chapter}{\normalfont\bfseries\huge}
\usepackage{setspace} % Line spacing
\onehalfspacing
% \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
\usepackage[unicode=true,bookmarks=true,bookmarksnumbered=true,
bookmarksopen=true,bookmarksopenlevel=1,breaklinks=false,
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{algorithm,algpseudocode}
\usepackage{bm} % bold greek variables (boldmath)
\usepackage{tikz}
\usetikzlibrary{positioning} % use: above left of, etc
% Improves general appearance of the text
\usepackage[protrusion=true,expansion=true, kerning]{microtype}
%---------------- equations packages --------------------------------------
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[thinc]{esdiff} % for derivatives
\usepackage{enumitem}
\numberwithin{equation}{section}
\numberwithin{algorithm}{section}
\numberwithin{table}{section}
%---------------- appendix and json --------------------------------------
%\usepackage{bera}% optional: just to have a nice mono-spaced font
\usepackage{listings}
%\usepackage{xcolor}
\usepackage[titletoc]{appendix}
\usepackage{booktabs} % for using pandas tables
\usepackage{adjustbox}
%---------------------------- for the random forest --------------------
\usetikzlibrary{fit,shapes.arrows,positioning}
\usepackage{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 ----------------
\newcommand{\secref}[1]{Section~\ref{#1}}
\newcommand{\chapref}[1]{Chapter~\ref{#1}}
\renewcommand{\eqref}[1]{Equation~(\ref{#1})}
\newcommand{\figref}[1]{Figure~\ref{#1}}
\newcommand{\tabref}[1]{Table~\ref{#1}}
% ------------------- 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
\let\mySection\section\renewcommand{\section}{\suppressfloats[t]\mySection}
\let\mySubSection\subsection\renewcommand{\subsection}{\suppressfloats[t]\mySubSection}
% ------------------- 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
\renewcommand{\vec}[1]{\mathbf{#1}}
\newcommand{\mat}[1]{\mathbf{#1}}
% tag equation with name
\newcommand{\eqname}[1]{\tag*{#1}}
% ------------------- pdf settings -------------------
% ADAPT THIS
\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
\newcommand{\alignedComment}[1]{\Comment{\parbox[t]{.35\linewidth}{#1}}}
% define a foreach command in algorithms
\algnewcommand\algorithmicforeach{\textbf{foreach}}
\algdef{S}[FOR]{ForEach}[1]{\algorithmicforeach\ #1\ \algorithmicdo}
然后我就像平常一样写,我没有使用任何特殊的东西,这是一个例子
\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}.
答案1
从离线代码来看,这主要是由于使用[H]
浮点数造成的。
这些大洞没有出现在工作电脑上,这或许纯粹是运气好。
一般建议不要使用[H]
,它只在非常专业的文档中有用。论文不是其中之一。