ulyngs / oxforddown

Template for writing an Oxford University thesis in R Markdown; uses the OxThesis LaTeX template and was inspired by thesisdown.
https://ulyngs.github.io/oxforddown/
MIT License
220 stars 80 forks source link

Linespacing varies amongst pages #73

Closed alexdank closed 1 year ago

alexdank commented 1 year ago

Hi,

I encounter a problem when knitting documents from the index.rmd file.

Here’s the problem: When knitting the _main thesis document, line spacing seems to be variable at some locations (see examples below):

image

image

I’ve got the feeling it has something to do with the placement of figures on the pages before or after the error, but I am not certain. Interestingly, when I knit the document as single chapter, the text does not behave like this. Do you have any clue what could be the issue? It would be of great help!

Below my sessioninfo

`> sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8   
[3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
`
alexdank commented 1 year ago

The problem can be more or less reduced by playing with the figure sizes, placements and forcing \newpage on some segments, but still varying linetypes appear (only differences between spacing is reduced now) and this process seems to be 'trial and error'.

ulyngs commented 1 year ago

Can you provide a minimally reproducible example where it occurs when knitting the full thesis but not a single chapter?

mtthwborg commented 1 year ago

I have this issue too, but it occurs both with the full thesis and a single chapter. Similarly to the OP, it also seems to occur between figures on different pages, where the text seems to increase in spacing to pad out the remaining page.

ulyngs commented 1 year ago

Can you provide a minimally reproducible example? And can you check if the spacing variations occur if you knit the same content to an ordinary PDF file (i.e. not using the oxforddown template)?

(I suspect that what you are describing is just LaTeX' normal behaviour?)

alexdank commented 1 year ago

Okay, I did some extensive googling and found out it is a result of setting the \setlength{\parskip}{ length} argument in the template.tex file. (see https://tex.stackexchange.com/questions/108978/variable-white-space-between-paragraphs). Hence, indeed it is normal latex behaviour, as latex automatically adjusts the spaces between each line in the paragraphs to fit the page, and this is influenced by for instance figure placements. Anyway, for me changing the values to the following 'solved' my problem -- The spacing differences were minimalized.

% UL: You can set the general paragraph spacing here - I've set it to 2pt (was 0) so % it's less claustrophobic \setlength{\parskip}{0.1pt plus 0.1pt}

ulyngs commented 1 year ago

@alexdank thanks for looking into this! Do you think there is any action for me here? That is, do you think I should change the oxforddown default settings for paragraph spacing?

alexdank commented 1 year ago

@ulyngs Considering I was not the only one with this 'issue' it might be advisable to reduce the default settings for paragraph spacing to avoid further 'issues' with other users. I think it is especially relevant for people that (like me) have many figures in one chapter, increasing the 'risk' of abnormal line spacing due to the parskip length settings.

ulyngs commented 1 year ago

How about I reduce the default paragraph spacing, but also make the spacing controllable from index.Rmd alongside an explanation of how to read the spacing settings?

(here's from the titlesec package, according to stackoverflow:

% spacing: how to read {12pt plus 4pt minus 2pt}
%           12pt is what we would like the spacing to be
%           plus 4pt means that TeX can stretch it by at most 4pt
%           minus 2pt means that TeX can shrink it by at most 2pt

btw @mtthwborg this should answer your query: in order to set a particular spacing as something that LaTeX should not be allowed to either stretch or shrink, you'd need to set it to e.g. {4pt plus 0pt minus 0pt} which would mean a 4 point spacing that LaTeX is neither allowed to make bigger nor smaller