该代码来自Knitr Texstudio的大块

发布于 2025-01-30 10:28:16 字数 781 浏览 5 评论 0原文

我在Texstudio中使用Knitr将我的R脚本包括在文档中,但问题是我的代码来自颜色块背景 “像这个景象”

这是我的代码示例

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\begin{document}
<<>>=

library(equatiomatic)
summary(cars)
extract_eq(lm(dist~speed,cars))
@

<<>>=
x <- rnorm(100)
y <- rnorm(100)
@

Throughout history, many people have wondered about the means of $x$ and $y$.
Today we can provide some answers. The mean of $x$ is approximately
\Sexpr{extract_eq(lm(dist~speed,cars))}. The mean of $y$ is approximately \Sexpr{round(mean(y), 3)}.
References

\end{document

I use knitr in texstudio to include my R script into my document, but the problem is my code comes out of the color chunk background
like this exemple

This is my code example

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\begin{document}
<<>>=

library(equatiomatic)
summary(cars)
extract_eq(lm(dist~speed,cars))
@

<<>>=
x <- rnorm(100)
y <- rnorm(100)
@

Throughout history, many people have wondered about the means of $x$ and $y$.
Today we can provide some answers. The mean of $x$ is approximately
\Sexpr{extract_eq(lm(dist~speed,cars))}. The mean of $y$ is approximately \Sexpr{round(mean(y), 3)}.
References

\end{document

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文