From 527c88fc2391c47bcd3f5ab2ec423688b424da10 Mon Sep 17 00:00:00 2001 From: "Joseph V. Casillas" Date: Tue, 17 Sep 2024 13:18:16 -0400 Subject: [PATCH 1/2] Update revision_letter.tex --- .../resources/revision_letter.tex | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/inst/rmarkdown/templates/revision_letter/resources/revision_letter.tex b/inst/rmarkdown/templates/revision_letter/resources/revision_letter.tex index 7052c826..bbb5b8a0 100644 --- a/inst/rmarkdown/templates/revision_letter/resources/revision_letter.tex +++ b/inst/rmarkdown/templates/revision_letter/resources/revision_letter.tex @@ -171,26 +171,34 @@ \subsection{} $if(csl-refs)$ +% definitions for citeproc citations +\NewDocumentCommand\citeproctext{}{} +\NewDocumentCommand\citeproc{mm}{% + \begingroup\def\citeproctext{#2}\cite{#1}\endgroup} +\makeatletter + % allow citations to break across lines + \let\@cite@ofmt\@firstofone + % avoid brackets around text for \cite: + \def\@biblabel#1{} + \def\@cite#1#2{{#1\if@tempswa , #2\fi}} +\makeatother \newlength{\cslhangindent} \setlength{\cslhangindent}{1.5em} \newlength{\csllabelwidth} \setlength{\csllabelwidth}{3em} -\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing - {% don't indent paragraphs - \setlength{\parindent}{0pt} +\newenvironment{CSLReferences}[2] % #1 hanging-indent, #2 entry-spacing + {\begin{list}{}{% + \setlength{\itemindent}{0pt} + \setlength{\leftmargin}{0pt} + \setlength{\parsep}{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} + \ifodd #1 + \setlength{\leftmargin}{\cslhangindent} + \setlength{\itemindent}{-1\cslhangindent} \fi - }% - {} -\usepackage{calc} -\newcommand{\CSLBlock}[1]{#1\hfill\break} -\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}} -\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} -\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} + % set entry spacing + \setlength{\itemsep}{#2\baselineskip}}} + {\end{list}} $endif$ \begin{document} From 64494e876daaf8a47bda92d2e261db3be6132fd8 Mon Sep 17 00:00:00 2001 From: crsh Date: Wed, 25 Sep 2024 13:19:23 +0200 Subject: [PATCH 2/2] Tables not numbered when knitting to word Fixes #594 --- inst/lua/docx_fixes.lua | 58 +++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/inst/lua/docx_fixes.lua b/inst/lua/docx_fixes.lua index 89489d02..40161034 100644 --- a/inst/lua/docx_fixes.lua +++ b/inst/lua/docx_fixes.lua @@ -10,30 +10,56 @@ function Header (elem) return elem end -function Image (img) - local caption = img.caption +function Figure (fig) + if fig.caption and #fig.caption.long > 0 then - if caption[1] ~= nil then - caption[1] = pandoc.Emph(caption[1]) - caption[3] = pandoc.Emph(string.gsub(pandoc.utils.stringify(caption[3]), ":", ". ")) + local caption = fig.caption.long[1].content + + if #caption >= 4 then + caption[2] = pandoc.Emph(caption[2]) + -- Remove the colon from the 4th element (if it's a string) + if caption[4] and pandoc.utils.stringify(caption[4]):match(":") then + caption[4] = pandoc.Str(string.gsub(pandoc.utils.stringify(caption[4]), ":", ".")) + end + end + + -- Assign the modified caption back to the table + fig.caption.long[1].content = caption end - return img + + -- Return the modified table + return fig end function Table (tbl) - local caption = tbl.caption.long[1].content + -- Check if tbl.caption.long is not empty + if tbl.caption and #tbl.caption.long > 0 then - if caption[1] ~= nil then - caption[3] = pandoc.Str(string.gsub(pandoc.utils.stringify(caption[3]), ":", "")) - caption[4] = pandoc.LineBreak() + local caption = tbl.caption.long[1].content - for i = 5, (#caption) do - caption[i] = pandoc.Emph(caption[i]) + -- Modify the caption only if there are enough elements + if #caption >= 4 then + -- Remove the colon from the 4th element (if it's a string) + if caption[4] and pandoc.utils.stringify(caption[4]):match(":") then + caption[4] = pandoc.Str(string.gsub(pandoc.utils.stringify(caption[4]), ":", "")) + end + + -- Add a line break as the 5th element + if #caption >= 5 then + caption[5] = pandoc.LineBreak() + else + table.insert(caption, 5, pandoc.LineBreak()) + end + + for i = 6, (#caption) do + caption[i] = pandoc.Emph(caption[i]) + end end - end - tbl.caption.long[1].content = caption + -- Assign the modified caption back to the table + tbl.caption.long[1].content = caption + end - return tbl + -- Return the modified table + return tbl end -