Home > Software design >  How can I stop a horizontal rule from indenting in rmarkdown LaTeX Tufte handout?
How can I stop a horizontal rule from indenting in rmarkdown LaTeX Tufte handout?

Time:03-01

I have an rmarkdown PDF Tufte handout with a horizontal rule on one line, where someone is supposed to sign the document. I would like the rule to be left justified with no indent, but \noindent isn't working. Reading about \noindent led me to believe that maybe it was being ignored because the line wasn't recognized as being a new line, but adding a paragraph break doesn't seem to work either.

My current thinking is that the horizontal rule might not be recognized as real text, so LaTeX just sees an empty line and ignores the \noindent, and I seem to remember that there's some non-printing character I could stick in there that would get it to be recognized, but I don't know what that is or how to search for it.

This same document was working for me recently, but broke when I updated R. And it's only a problem with the Tufte handout. In a normal LaTeX PDF document the \noindent works fine.

---
output:
  tufte::tufte_handout: default
  tufte::tufte_pdf: default
---

Here's where someone should sign, but rules are indented:

\vspace{22pt}  

\noindent\rule{7.3cm}{0.4pt}\hspace{.3cm}\rule{3cm}{0.4pt}  

\noindent Signer\hspace{6.7cm}Date  

\vspace{30pt}  

Still doesn't work with paragraph break:

\vspace{22pt}  

\par\noindent\rule{7.3cm}{0.4pt}\hspace{.3cm}\rule{3cm}{0.4pt}  

\noindent Signer\hspace{6cm}Date 

\vspace{30pt}

I can indent the text to match, but I don't like the look:

\vspace{22pt}  

\rule{7.3cm}{0.4pt}\hspace{.3cm}\rule{3cm}{0.4pt}  

\indent Signer\hspace{6.7cm}Date  

\vspace{30pt} 

Thanks in advance for any ideas.

CodePudding user response:

Your latex code is correct, but the conversation from rmarkdown to latex butchers it up by adding line breaks after \noindent (which makes zero sense...).

You can avoid the problem like this:

---
output:
  tufte::tufte_handout: 
    keep_tex: true
  tufte::tufte_pdf: default

---

Here's where someone should sign, but rules are indented:

\vspace{22pt}  

```{=latex}
\noindent\rule{7.3cm}{0.4pt}\hspace{.3cm}\rule{3cm}{0.4pt}  
```

\noindent Signer\hspace{6.7cm}Date  

enter image description here

  • Related