I wanted to try using LaTeX in Scrivener. I loaded the TEX template but don’t really know how I would use this. I tried pasting some LaTeX code in Scrivener, but it has all the markup, and compiles a PDF with the markup listed. Here is a simple tex document that I was trying out, but I can’t figure out a way of editing it in Scrivener:

\documentclass[10pt]{scrartcl}

\usepackage[inner=.5in, outer=1in, top=.75in, bottom=.75in]{geometry}

\usepackage{amssymb}

\usepackage{amsmath}

\usepackage{lmodern}

\usepackage{fontspec,xltxtra,xunicode}

\defaultfontfeatures{Mapping=tex-text}

\setromanfont[Mapping=tex-text]{DTL Valiance TPRO}

\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{DTL Caspari TOT Medium}

\setmonofont[Scale=MatchLowercase]{Andale Mono}

\usepackage{commath}

\raggedbottom

\title{Proof of Schwartz Inequality}

\date{\vspace{-5ex}}

\begin{document}

\maketitle

Prove $$x_1y_1+x_2y_2\leq\sqrt{x_1^2+x_2^2}\sqrt{y_1^2+y_2^2}$$\

It is helpful to assume it is true and then work backwards:

\begin{align*}

x_1y_1+x_2y_2 &\overset{?}{\leq}\sqrt{(x_1^2+x_2^2)}\sqrt{y_1^2+y_2^2}\

(x_1y_1+x_2y_2)^2 &\overset{?}{\leq}(x_1^2+x_2^2)(y_1^2+y_2^2)\

(x_1y_1+x_2y_2)^2 &\overset{?}{\leq}x_1^2y_1^2+x_2^2y_2^2+x_1^2y_2^2+x_2^2y_1^2\

x_1^2y_1^2+x_2^2y_2^2+2x_1x_2y_1y_2 &\overset{?}{\leq} x_1^2y_1^2+x_2^2y_2^2+x_1^2y_2^2+x_2^2y_1^2\

2x_1x_2y_1y_2 &\overset{?}{\leq} x_1^2y_2^2+x_2^2y_1^2\

0 &\overset{?}{\leq} x_1^2y_2^2+x_2^2y_1^2-2x_1x_2y_1y_2 \

0 &\overset{?}{\leq} (x_1y_2)^2-2x_1x_2y_1y_2+(x_2y_1)^2 \

0 &\overset{?}{\leq} (x_1y_2-x_2y_1)^2 \

\end{align*}

The last statement is true, since all squares are $\ge$ 0\

So to prove this

\begin{align*}

0 &\leq (x_1y_2-x_2y_1)^2 \

0 &\leq (x_1y_2)^2-2x_1x_2y_1y_2+(x_2y_1)^2 \

0 &\leq x_1^2y_2^2+x_2^2y_1^2-2x_1x_2y_1y_2 \

2x_1x_2y_1y_2 &\leq x_1^2y_2^2+x_2^2y_1^2\

x_1^2y_1^2+x_2^2y_2^2+2x_1x_2y_1y_2 &\leq x_1^2y_1^2+x_2^2y_2^2+x_1^2y_2^2+x_2^2y_1^2\

(x_1y_1+x_2y_2)^2 &\leq x_1^2y_1^2+x_2^2y_2^2+x_1^2y_2^2+x_2^2y_1^2\

(x_1y_1+x_2y_2)^2 &\leq(x_1^2+x_2^2)(y_1^2+y_2^2)\

x_1y_1+x_2y_2 &\leq\sqrt{x_1^2+x_2^2}\sqrt{y_1^2+y_2^2}\

\end{align*}

Proof of general form $\sum\limits_{i=1}^n x_iy_i \leq \sqrt{\sum\limits_{i=1}^n x_i^2} \sqrt{\sum\limits_{i=1}^n y_i^2} $\[2em]

Start with the general form of the first proof and work backwards:

\begin{align*}

\sum\limits_{i=1}^n\sum\limits_{j=1}^n (x_iy_j-x_jy_i)^2 &= \sum\limits_{i=1}^n x_i^2 \sum\limits_{j=1}^n y_j^2+\sum\limits_{i=1}^n y_i^2 \sum\limits_{j=1}^n x_j^2-2\sum\limits_{i=1}^n x_iy_i\sum\limits_{j=1}^n x_j y_j\

\sum\limits_{i=1}^n\sum\limits_{j=1}^n (x_iy_j-x_jy_i)^2 &= 2\biggl(\sum\limits_{i=1}^n x_i^2\biggr)\biggl(\sum\limits_{i=1}^n y_i^2\biggr)-2\biggl(\sum\limits_{i=1}^n x_i y_i\biggr)^2\

0&\leq 2\biggl(\sum\limits_{i=1}^n x_i^2\biggr)\biggl(\sum\limits_{i=1}^n y_i^2\biggr)-2\biggl(\sum\limits_{i=1}^n x_i y_i\biggr)^2\

0&\leq \biggl(\sum\limits_{i=1}^n x_i^2\biggr)\biggl(\sum\limits_{i=1}^n y_i^2\biggr)-\biggl(\sum\limits_{i=1}^n x_i y_i\biggr)^2\

\biggl(\sum\limits_{i=1}^n x_i y_i\biggr)^2&\leq \sum\limits_{i=1}^n x_i^2\sum\limits_{i=1}^n y_i^2\

\sum\limits_{i=1}^n x_iy_i &\leq \sqrt{\sum\limits_{i=1}^n x_i^2} \sqrt{\sum\limits_{i=1}^n y_i^2}

\end{align*}

\end{document}