admin管理员组文章数量:1426932
Quarto renders inline code (specified using backticks) in a very clear way when output to html: it changes the font, text color, and background color. But when outputting to PDF, it only changes the font, which is so subtle a change that most readers won't even notice. How do I manually change the formatting of inline code in a PDF document to match the formatting used in html documents?
Here's the default formatting of inline code in a quarto html document:
---
title: "test"
format: html
---
Use something like `this code` to do something.
And here's the default formatting when output to PDF:
---
title: "test"
format: pdf
---
Use something like `this code` to do something.
Quarto renders inline code (specified using backticks) in a very clear way when output to html: it changes the font, text color, and background color. But when outputting to PDF, it only changes the font, which is so subtle a change that most readers won't even notice. How do I manually change the formatting of inline code in a PDF document to match the formatting used in html documents?
Here's the default formatting of inline code in a quarto html document:
---
title: "test"
format: html
---
Use something like `this code` to do something.
And here's the default formatting when output to PDF:
---
title: "test"
format: pdf
---
Use something like `this code` to do something.
Share
Improve this question
asked Jan 17 at 16:10
filups21filups21
1,9471 gold badge23 silver badges30 bronze badges
1 Answer
Reset to default 2You can tweak \texttt
, e.g. providing the gray background color and the purple font color from HTML
output:
\definecolor{codefontcolor}{RGB}{125,18,186}
\definecolor{codebggray}{HTML}{f8f9fa}
\let\textttOrig\texttt
\renewcommand{\texttt}[1]{\textttOrig{\colorbox{codebggray}{\textcolor{codefontcolor}{#1}}}}
Using the default font, it would look like this in a .pdf
:
Compared to the output in a .html
:
You can also change the used font in .pdf
output, one example is Source Code Pro:
\usepackage{sourcecodepro}
---
title: "test"
format:
pdf:
include-in-header:
text: |
\usepackage{sourcecodepro}
\definecolor{codefontcolor}{RGB}{125,18,186}
\definecolor{codebggray}{HTML}{f8f9fa}
\let\textttOrig\texttt
\renewcommand{\texttt}[1]{\textttOrig{\colorbox{codebggray}{\textcolor{codefontcolor}{#1}}}}
---
Use something like `this code` to do something.
本文标签: Change how inline code is formatted in quarto PDF outputStack Overflow
版权声明:本文标题:Change how inline code is formatted in quarto PDF output - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745356022a2655056.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论