Sharedlatex-tests / 2018-01-28-210904.texOpen in CoCalc
Authors: harald @schil.ly, Testing CoCalc, John Jeng, Harald Schilly, Harald Schilly, ℏal Snyder, William A. Stein
1
\documentclass{article}\usepackage[]{graphicx}\usepackage[]{color}
2
%% maxwidth is the original width if it is less than linewidth
3
%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
4
\makeatletter
5
\def\maxwidth{ %
6
\ifdim\[email protected]@width>\linewidth
7
\linewidth
8
\else
9
\[email protected]@width
10
\fi
11
}
12
\makeatother
13
14
\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}
15
\newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}%
16
\newcommand{\hlstr}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}%
17
\newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}%
18
\newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}%
19
\newcommand{\hlstd}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}%
20
\newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}%
21
\newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}%
22
\newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}%
23
\newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}%
24
\let\hlipl\hlkwb
25
26
\usepackage{framed}
27
\makeatletter
28
\newenvironment{kframe}{%
29
\def\[email protected]@[email protected]{}%
30
\ifinner\ifhmode%
31
\def\[email protected]@[email protected]{\end{minipage}}%
32
\begin{minipage}{\columnwidth}%
33
\fi\fi%
34
\def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
35
\colorbox{shadecolor}{##1}\hskip-\fboxsep
36
% There is no \\@totalrightmargin, so:
37
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
38
\MakeFramed {\advance\hsize-\width
39
\@totalleftmargin\[email protected] \linewidth\hsize
40
\@setminipage}}%
41
{\par\unskip\endMakeFramed%
42
\[email protected]@[email protected]}
43
\makeatother
44
45
\definecolor{shadecolor}{rgb}{.97, .97, .97}
46
\definecolor{messagecolor}{rgb}{0, 0, 0}
47
\definecolor{warningcolor}{rgb}{1, 0, 1}
48
\definecolor{errorcolor}{rgb}{1, 0, 0}
49
\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX
50
51
\usepackage{alltt}
52
\usepackage[utf8]{inputenc}
53
\usepackage[T1]{fontenc}
54
\usepackage{url}
55
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
56
\begin{document}
57
58
% learn more about knitr: https://yihui.name/knitr/
59
60
61
62
\title{Knitr in SMC}
63
64
\author{Author Name}
65
66
\maketitle
67
68
\begin{knitrout}
69
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
70
\begin{alltt}
71
\hlstd{x} \hlkwb{<-} \hlkwd{c}\hlstd{(}\hlnum{2}\hlstd{,}\hlnum{3}\hlstd{,}\hlnum{4}\hlstd{,}\hlnum{5}\hlstd{,}\hlnum{1}\hlstd{,}\hlnum{2}\hlstd{,}\hlnum{3}\hlstd{,}\hlnum{2}\hlstd{,}\hlnum{1}\hlstd{)}
72
\hlkwd{summary}\hlstd{(x)}
73
\end{alltt}
74
\begin{verbatim}
75
## Min. 1st Qu. Median Mean 3rd Qu. Max.
76
## 1.000 2.000 2.000 2.556 3.000 5.000
77
\end{verbatim}
78
\end{kframe}
79
\end{knitrout}
80
81
\begin{knitrout}
82
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
83
\begin{alltt}
84
\hlkwd{hist}\hlstd{(x)}
85
\end{alltt}
86
\end{kframe}
87
\includegraphics[width=.4\linewidth]{figure/histogram-plot-1}
88
89
\end{knitrout}
90
91
Sum of 2+3+4+5+1+2+3+2+1 is 23.
92
93
94
\end{document}
95
96
97