Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird behavior in References #133

Closed
bttomio opened this issue Mar 4, 2021 · 8 comments
Closed

Weird behavior in References #133

bttomio opened this issue Mar 4, 2021 · 8 comments
Assignees

Comments

@bttomio
Copy link

bttomio commented Mar 4, 2021

There is a weird behavior in the references section appearing to me. I am just creating a new file, naming it "index" and knitting it.

After the section title, the number 10 appears in the first line (weird behavior). Please see it here:

Screenshot from 2021-03-04 21-32-30

Thanks a lot for your package! It's awesome.

> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
 [1] compiler_4.0.3    bookdown_0.21     htmltools_0.5.1.1 tools_4.0.3       yaml_2.2.1       
 [6] remotes_2.2.0     rmarkdown_2.7     knitr_1.31        xfun_0.21         digest_0.6.27    
[11] thesisdown_0.1.0  rlang_0.4.10      evaluate_0.14 
@ismayc
Copy link
Owner

ismayc commented Mar 4, 2021

Very strange indeed. I'm not able to reproduce with

R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
 [1] compiler_4.0.3    bookdown_0.21     htmltools_0.5.1.1
 [4] tools_4.0.3       yaml_2.2.1        remotes_2.2.0    
 [7] rmarkdown_2.7     knitr_1.31        xfun_0.21        
[10] digest_0.6.27     packrat_0.5.0     thesisdown_0.1.0 
[13] rlang_0.4.10      evaluate_0.14    

I'm going to try on rstudio.cloud right now as well.

@ismayc
Copy link
Owner

ismayc commented Mar 4, 2021

Getting the same 10 on rstudio.cloud with

R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8    
 [5] LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C             
 [9] LC_ADDRESS=C           LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

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

loaded via a namespace (and not attached):
 [1] compiler_4.0.3    here_1.0.1        bookdown_0.21     rprojroot_2.0.2   htmltools_0.5.1.1
 [6] tools_4.0.3       yaml_2.2.1        remotes_2.2.0     rmarkdown_2.7     knitr_1.31       
[11] xfun_0.21         digest_0.6.27     thesisdown_0.1.0  rlang_0.4.10      evaluate_0.14   

Investigating further now.

@bttomio
Copy link
Author

bttomio commented Mar 4, 2021

Glad you could replicate it. Thanks! Just to add more information, I've tried other bib files. The weird behavior persisted.

@ismayc
Copy link
Owner

ismayc commented Mar 4, 2021

Based on my cloning and building https://github.com/rstudio/bookdown-demo with template: template.tex and bookdown::pdf_book and also getting the 10 there on Linux, it looks like this is something in the template.tex file. Still digging...

@ismayc
Copy link
Owner

ismayc commented Mar 4, 2021

It looks like I'll need to make one more change to the csl-refs code (Lines 119 - 130 of template.tex) to get this to work. The {rticles} package suggests replacing this with

$if(csl-refs)$
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
% for Pandoc 2.8 to 2.10.1
\newenvironment{cslreferences}%
  {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}%
  \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}%
  {\par}
% For Pandoc 2.11+
\newenvironment{CSLReferences}[3] % #1 hanging-ident, #2 entry spacing
 {% don't indent paragraphs
  \setlength{\parindent}{0pt}
  % turn on hanging indent if param 1 is 1
  \ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi
  % set entry spacing
  \ifnum #2 > 0
  \setlength{\parskip}{#2\baselineskip}
  \fi
 }%
 {}
\usepackage{calc} % for calculating minipage widths
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
$endif$

This is working for me on both Linux and Mac. Can you try it out and let me know if it works for you and then I'll update {thesisdown} to hopefully have this resolved?

@bttomio
Copy link
Author

bttomio commented Mar 5, 2021

That works perfectly! Here is the image:

Screenshot from 2021-03-05 08-52-06

Thank you very much, @ismayc!

@bttomio bttomio closed this as completed Mar 5, 2021
@ismayc
Copy link
Owner

ismayc commented Mar 5, 2021

You're welcome! Thanks for bringing this up.

@github-actions
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org whenever possible) and link to this issue. If a reprex is not applicable, recording a short Loom video showing what you are seeing can go a long way in helping to diagnose problems.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants