I am using Notion for my studies: so I have to use Latex to represent the equations or others math stuffs. I noticed that I can use the Newtonian notation on Latex with the command \dot or \ddot (first derivative and second derivative) but I cannot represent the third with \dddot or with something else. Is there a way to represent that?
As in this other answer, three dots (\dddot) and four dots (\ddddot) in math mode require the package amsmath.
So you have either
\documentclass{article}
\begin{document}
\[\dot{x}\]
\[\ddot{x}\]
\end{document}
or
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[\dot{x}\]
\[\ddot{x}\]
\[\dddot{x}\]
\[\ddddot{x}\]
\end{document}
Related
I have been trying for days to figure out how to write this formula in R markdown...
...but I didn't find anything on the web.
Can you help me please?
Thanks.
You can use something like that
\documentclass{article}
\begin{document}
\[
x_1 = \left(\begin{array}{c}x_{11}\\\vdots\\x_{1p}\end{array}\right),
\cdots,
x_n = \left(\begin{array}{c}x_{n1}\\\vdots\\x_{np}\end{array}\right)
\]
\end{document}
The array is used to stack elements and the \left( \right) pair provides the enclosing parenthesis.
Does not require any package and can probably be pasted as is in R.
I'm writing mainly in LaTeX, but some co-authors prefer MS Word. To facilitate their work a bit, I would like to convert the .tex file (or the .pdf) to a .docx. The formatting does not need to be perfect, but all of the text, equations, figures etc should be perfectly readable.
I'm currently thinking to take the .tex document, replace all the essential stuff and then let Pandoc do it's magic. For this I would preferably implement my additions as a Pandoc filter. E.g., my tikz pictures would be converted to png using the tikz.py filter provided with Pandoc. The problem I'm facing with this approach is that Pandoc tries to interpret the tikz environment upon conversion from tex into it's internal language and the filters take this internal language as an input. The result is that the tikz code is lost. Is there a way to tell Pandoc to leave any tikzpicture environments alone?
Edit:
See the MWE below:
MWE.tex contents:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (2,2);
\end{tikzpicture}
\end{document}
Output of pandoc -t native MWE.tex
[Para [Str "(0,0)",Space,Str "\8211",Space,Str "(2,2);"]]
The \draw command has completely disappeared as you can see.
I found that pandoc does not skip code encapsulated in \iffalse ... \fi, so you can redefine the tikpicture environment as such (or in any other way you might like):
\documentclass{article}
\usepackage{tikz}
\iffalse
\renewenvironment{tikzpicture}%
{\par---start tikzpicture---\\}%
{\\---end tikzpicture---\par}
\renewcommand{\node}{node:}
\fi
\begin{document}
\begin{tikzpicture}
\node {foo};
\end{tikzpicture}
\end{document}
With pandoc 2.5 this results in a docx file containing:
—start tikzpicture—
node:foo;
—end tikzpicture—
This feels very wrong, and I wish I knew a nicer way.
Using knitr to create a pdf, codechunks break according to page breaks. Usually this is exactly what I want, but in some cases I would like to be able to avoid this. E.g. by making a code-chunk jump to the next page if it does not fit the current page. I would prefer if this could be done in a chunk option, I.E not using eg. \newpage etc.
The following is an example of a code-chunk that breaks. How do I avoid this?
\documentclass{article}
\usepackage[english]{babel}
\usepackage{lipsum}
\begin{document}
\lipsum[1-3] \textbf{The following chunk will break. How do I avoid this breaking? }
<<echo=TRUE>>=
(iris)[1:20,]
#
\end{document}
I left an empty environment knitrout in the knitr design for such purposes. You can redefine this environment to achieve what you want. There are many LaTeX environments that are non-breakable, such as a figure environment. Below I use the minipage environment as an example:
\documentclass{article}
\renewenvironment{knitrout}{\begin{minipage}{\columnwidth}}{\end{minipage}}
% alternatively, you can use `figure`
% \renewenvironment{knitrout}{\begin{figure}}{\end{figure}}
\begin{document}
\begin{figure}
\caption{One figure.}
\end{figure}
% placeholder
\framebox{\begin{minipage}[t][0.3\paperheight]{1\columnwidth}%
nothing
\end{minipage}}
<<echo=TRUE>>=
(iris)[1:20,]
#
\begin{figure}
\caption{Another one.}
\end{figure}
\end{document}
I would like to make an R code chunk (in Sweave) printed inside a framed box in the resulting pdf.
Is there an easy solution for doing that?
The short answer is that yes, there is an easy way. Just add the following lines, or something like them to the preamble of your Sweave document:
\DefineVerbatimEnvironment{Sinput}{Verbatim} {xleftmargin=2em,
frame=single}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{xleftmargin=2em,
frame=single}
This works because the appearance of code (and output) chunks is controlled by the definition of the Sinput and Soutput environments. These are both Verbatim environments as provided by the LaTeX package fancyvrb. (Click here for a 73 page pdf describing the numerous options that fancyvrb provides).
A quick look in the file Sweave.sty reveals the default definition of those two environments:
\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl}
To change those definitions, just add \DefineVerbatimEnvironment statements of your own devising either: (a) at the end of the Sweave.sty file; or (b) at the start of your *.Snw document.
Finally, here's an example to show what this looks like in practice:
\documentclass[a4paper]{article}
\usepackage{Sweave}
\DefineVerbatimEnvironment{Sinput}{Verbatim} {xleftmargin=2em,
frame=single}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{xleftmargin=2em,
frame=single}
\title{Sweave with boxes}
\begin{document}
\maketitle
<<echo=FALSE>>=
options(width=60)
#
Here is an example of a code chunk followed by an output chunk,
both enclosed in boxes.
<<>>=
print(rnorm(99))
#
\end{document}
knitr, a successor of Sweave, by default outputs all echoed R code in boxes, and also formats it to the margins. Other nice features include syntax coloring and PGF integration.
Sweave code of average complexity needs only minor if any adaptions to run with knitr.
Is it possible to place a character or a formula below an other part of a larger formula in Latex?
foo f(x) = ...
x
In case that this example is not clear. I'd like to make one of my custom functions - just defined as \text{foo} in a math environment - look like one of the built-in functions like sum, min or max which accept parameters that are placed above or below the function symbol.
Simply using \text{foo}_x does not work.
The function you're looking for is \underset provided by the amsmath package. Here's an example:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\underset{below}{above}$
\end{document}
Output:
You can declare the foo as a math operator. Then use it in any equation environment. See below
\DeclareMathOperator*{\foo}{foo} %in preamble
\begin{align}
\foo_x f(x) = ...
\end{align}
Following the line of the answer by #hanoosh, if you need you can even do:
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\foo}{foo}
\begin{document}
\begin{displaymath}
\foo_{x\atop y} f(x,y)
\end{displaymath}
\end{document}
Only \DeclareMathOperator* is powered by package amsmath while, for example,
\documentclass{article}
\begin{document}
\begin{displaymath}
\sum_{x\atop y} f(x,y)
\end{displaymath}
\end{document}
compiles not needing any AMS package.