Skip to content

Instantly share code, notes, and snippets.

@violetguos
Last active May 16, 2018 20:34
Show Gist options
  • Save violetguos/bfd055a6a5f49bac9cf1a373f2445440 to your computer and use it in GitHub Desktop.
Save violetguos/bfd055a6a5f49bac9cf1a373f2445440 to your computer and use it in GitHub Desktop.
#!/bin/bash
lyx --export latex master.lyx
lyx --export latex intro.lyx
lyx --export latex appendix.lyx
bibtex main
pdflatex main.tex
# diff
latexdiff --exclude-textcmd="section,subsection" master_submitted.tex master.tex > master_diff.tex
latexdiff --exclude-textcmd="section,subsection" intro_submitted.tex intro.tex > intro_diff.tex
bibtex main_diff
pdflatex main_diff.tex
# display
evince main_diff.pdf
%coloured box, text
\begin{tcolorbox}
A physical explanation the \emph{dynamic matrix}\\
lots of text\\
a new line\\
equation
\begin{equation}
%\label{eq:dynamic_diag}
\nonumber
\bm C \bm D \bm C^{\dagger}=\bm \Omega = \left(\begin{array}{cccc}
\omega^2_1 & 0 & ... & 0\\
0 & \omega^2_2 & ... & 0\\
\vdots & & \ddots & \vdots \\
0 & 0 & ... & \omega^2_{Nd}
\end{array}\right),
\end{equation}
where $\bm C$ is a unitary matrix (each column is one of the eigenvectors of the dynamic matrix $\bm D$), $Nd$ is the product of the number of particlces, $N$, and the number of dimensions, $d$.
\end{tcolorbox}
%coloured equation
\documentclass{article}
\usepackage{color}
\definecolor{myblue}{rgb}{.8, .8, 1}
\usepackage{amsmath}
\usepackage{empheq}
\newlength\mytemplen
\newsavebox\mytempbox
\makeatletter
\newcommand\mybluebox{%
\@ifnextchar[%]
{\@mybluebox}%
{\@mybluebox[0pt]}}
\def\@mybluebox[#1]{%
\@ifnextchar[%]
{\@@mybluebox[#1]}%
{\@@mybluebox[#1][0pt]}}
\def\@@mybluebox[#1][#2]#3{
\sbox\mytempbox{#3}%
\mytemplen\ht\mytempbox
\advance\mytemplen #1\relax
\ht\mytempbox\mytemplen
\mytemplen\dp\mytempbox
\advance\mytemplen #2\relax
\dp\mytempbox\mytemplen
\colorbox{myblue}{\hspace{1em}\usebox{\mytempbox}\hspace{1em}}}
\makeatother
\begin{document}
\begin{empheq}[box={\mybluebox[5pt]}]{equation*}
c_i = \sum_j A_{ij}
\end{empheq}
\begin{empheq}[box={\mybluebox[2pt][2pt]}]{equation*}
c_i = \langle\psi|\phi\rangle
\end{empheq}
\end{document}
%%%%%%%%%%%%%%%%%%%code format%%%%%%%%%%%%%%%%
https://www.sharelatex.com/learn/Code_Highlighting_with_minted
\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\makeatletter
\def\underbrace#1{%
\@ifnextchar_{\tikz@@underbrace{#1}}{\tikz@@underbrace{#1}_{}}}
\def\tikz@@underbrace#1_#2{%
\tikz[baseline=(a.base)] {\node[inner sep=2] (a) {\(#1\)};
\draw[line cap=round,decorate,decoration={brace,amplitude=4pt}]
(a.south east) -- node[pos=0.5,below,inner sep=7pt] {\(\scriptstyle #2\)} (a.south west);}}
\def\overbrace#1{%
\@ifnextchar^{\tikz@@overbrace{#1}}{\tikz@@overbrace{#1}^{}}}
\def\tikz@@overbrace#1^#2{%
\tikz[baseline=(a.base)] {\node[inner sep=2] (a) {\(#1\)};
\draw[line cap=round,decorate,decoration={brace,amplitude=4pt}]
(a.north west) -- node[pos=0.5,above,inner sep=7pt] {\(\scriptstyle #2\)} (a.north east);}}
\makeatother
\begin{document}
Test with braces:
\begin{equation}
\underbrace{ABCD}_{\text{this is a test}} + DEFG = \overbrace{HIJK}^{\text{this is a test}}
\end{equation}
\end{document}
\documentclass{article}
% \usepackage{amsmath}
\usepackage{mathtools}% Loads amsmath
\begin{document}
\[
f(x) =
\underbrace{(x + 2)^3}_\text{text 1} +
\bigl(
\mathrlap{\overbrace{\phantom{(c - 2d)}}^{\text{text 2}}}
(c -
\mathrlap{\underbrace{\phantom{2d) + (3e}}_{\text{text 3}}}
2d) +
\overbrace{(3e - 4f)}^{\text{text 4}}
\bigr) +
\overbrace{(x - 3)}^\text{text 5}
\]
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment