rstudio / rticles

LaTeX Journal Article Templates for R Markdown
https://pkgs.rstudio.com/rticles/
1.46k stars 516 forks source link

onehalfspacing causes overlapping of titles and text #535

Open jajberni opened 1 year ago

jajberni commented 1 year ago

The package onehalfspacing seems to cause some overlapping in the titles of sections and sub-sections.

https://github.com/rstudio/rticles/blob/3cb3a3cc6b7fa4188c4358c0e319568c05703171/inst/rmarkdown/templates/frontiers/resources/template.tex#L17

image

Commenting the line or adding explicit title spacing seems to fix it.

\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\usepackage[onehalfspacing]{setspace}
cderv commented 1 year ago

This is part of the Frontiers template 🤔 https://www.frontiersin.org/guidelines/author-guidelines

So I could remove it here, but is this a specific effect expected by Frontiers Journals ?

Is their template broken ?

Maybe this is something else conflicting with this Frontiers requirements settings that we added for some Pandoc's feature support 🤔

jajberni commented 1 year ago

That's right; I didn't realize the template comes from Frontiers. It only happens on certain occasions, which I haven't deciphered yet, but it is quite annoying. I have avoided it by introducing some empty lines or breaking the sentence, but it is not ideal. I will investigate a bit further and try to replicate it with the original template downloaded from Frontiers.

jajberni commented 1 year ago

It looks like the template is a bit outdated. https://github.com/frontiersin/latex-manuscript-templates/tree/master/Frontiers_LaTex_Templates

In any case, I am unsure if this is the root of the problem.

cderv commented 1 year ago

Oh didn't know about the github repo. Maybe an issue can be opened there ?

I don't know how often journals updates their template, nor if the content is mandatory or not.

@muschellij2 you added the format in #211 -do you have insight if this is safe to remove this part of the template ?

Otherwise what I can do maybe is

jajberni commented 1 year ago

I have forked the repo and updated the templates to match the template and example from Frontiers:

b9bb1e0ab421c25faeae95407b9651c8839b790f

Knitting the same RMarkdown with this version seems to fix my problem:

image

As part of the 'migration', I have done the following:

Also, I am not sure how to add the option for generating a template for the supplemental material, which uses a different tex template and format. It is quite a simple tex file, so maybe the best would be just to include the sample template and leave the user the option of modifying it.

Happy to get some feedback before creating a PR.

cderv commented 1 year ago

I have forked the repo and updated the templates to match the template and example from Frontiers:

So you are saying that the template in rticles needs an update to match latest from Frontier ? If that is a case, PR welcome for sure !

Added the extra optional fields in the affiliation: laboratory and Institute

✅

Added a couple of examples for equations and cross-references to the equations

In the skeleton.Rmd ? I think so... ✅

Added a couple of examples for adding existing graphics (pdf, eps) and with code, as well as showing how to cross-reference the graphs

All good also ✅

Also, I am not sure how to add the option for generating a template for the supplemental material, which uses a different tex template and format. It is quite a simple tex file, so maybe the best would be just to include the sample template and leave the user the option of modifying it.

This is another file completely ? Like it would be a new companion Rmd file ?

I am not sure to understand how this is working, but we can do a lot in the format function. There is possibility to do a post processing steps and generate another doc if needed.

Manually how does the supplemental materiel works ? You write you article and then you write another doc ?

Happy to get some feedback before creating a PR.

You can send it and we'll discuss in the PR ! Thank you very much for your help !

jajberni commented 1 year ago

I have forked the repo and updated the templates to match the template and example from Frontiers:

So you are saying that the template in rticles needs an update to match latest from Frontier ? If that is a case, PR welcome for sure !

Added the extra optional fields in the affiliation: laboratory and Institute

✅

Added a couple of examples for equations and cross-references to the equations

In the skeleton.Rmd ? I think so... ✅ Yes, that's right!

Added a couple of examples for adding existing graphics (pdf, eps) and with code, as well as showing how to cross-reference the graphs

All good also ✅

Also, I am not sure how to add the option for generating a template for the supplemental material, which uses a different tex template and format. It is quite a simple tex file, so maybe the best would be just to include the sample template and leave the user the option of modifying it.

This is another file completely ? Like it would be a new companion Rmd file ?

That is right, the problem is that it would need a different template.tex, which I don't know if that would be a problem, or how to manage it.

I am not sure to understand how this is working, but we can do a lot in the format function. There is possibility to do a post processing steps and generate another doc if needed.

Manually how does the supplemental materiel works ? You write you article and then you write another doc ?

The idea situation is:

  1. You write your article with your Rmd template, as usual
  2. In case you need to add supplemental material, you write another Rmd based on a suppmat_template.Rmd with a different document class and template.tex.

However, as far as I can tell, there in always only one template.tex in the resources file. Right?

Happy to get some feedback before creating a PR.

You can send it and we'll discuss in the PR ! Thank you very much for your help !

Sounds great, I'll make sure I remove any unnecessary files and proceed with the PR. We can resolve the supplemental material issue later on.

cderv commented 1 year ago

I think there is some solutions for the supplementary part, either using a different format, or just switching template used based on a value from an argument in the format.

We could also imagine something where you write your supp material in the same main Rmd like in

# Supplementary Material {#supp}

<content here>

and then we catch this and copy to a different document, and render with a different template.

Anything seems possible - from the more manual to the more automated. We need to find the good balance!