├── .gitignore ├── README.md ├── bending-edges-with-tikz.tex ├── booktabs_thick_line.tex ├── boxplot.tex ├── changes-bug.tex ├── chapterbib ├── README.md ├── compilationscript.bash ├── discussion.tex ├── introduction.tex ├── main.pdf ├── main.tex ├── material.tex └── results.tex ├── circles.tex ├── clipping_image.tex ├── code-listing.tex ├── combine-pdfs.tex ├── draw_a_scalebar.py ├── embedded_movie.tex ├── enclosing-some-points.tex ├── filesize_test.tex ├── formulas.tex ├── fourier_series_expansion.m ├── fourier_series_expansion.tex ├── full_page_pdf.tex ├── headers.tex ├── highlight-region-in-pgf-plot.tex ├── image_on_image.tex ├── img1.png ├── img2.png ├── labels.tex ├── makefile ├── minimal.tex ├── movie.avi ├── multi-axis-plot.tex ├── multiple_affiliations.tex ├── node-positioning.tex ├── plotting_multiple_files_and_legends.tex ├── randomwalk.tex ├── redefine-subfloat-caption.tex ├── rose.tex ├── scale_bars.tex ├── scalebar.m ├── scalebar.tex ├── scalebarimage.jpg ├── serial-letter.tex ├── sizing.tex ├── subcaption.tex ├── table_alignment.tex ├── tikz-timing.tex ├── vertical_space_before_table.tex ├── waferdiameter.tex ├── watermark.tex └── wide-table-with-long-cells.tex /.gitignore: -------------------------------------------------------------------------------- 1 | *.aux 2 | *.bbl 3 | *.blg 4 | *.dvi 5 | *.fdb_latexmk 6 | *.glg 7 | *.glo 8 | *.gls 9 | *.idx 10 | *.ilg 11 | *.ind 12 | *.ist 13 | *.loc 14 | *.lof 15 | *.log 16 | *.lot 17 | *.maf 18 | *.mtc 19 | *.mtc0 20 | *.nav 21 | *.nlo 22 | *.out 23 | *.pdf 24 | *.pdfsync 25 | *.ps 26 | *.snm 27 | *.synctex.gz 28 | *.toc 29 | *.vrb 30 | matlab2tikz* 31 | NUL 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LaTeX code and snippets 2 | ======================= 3 | 4 | Here are some LaTeX-files I've written/copied/hacked together over the years. 5 | 6 | Compile the code with `pdflatex` 7 | -------------------------------------------------------------------------------- /bending-edges-with-tikz.tex: -------------------------------------------------------------------------------- 1 | % Answer for http://tex.stackexchange.com/a/121348/828, which I was also answered (more thorougly, but with equal endresult) by "Torbjørn T." some minutes before me: http://tex.stackexchange.com/a/121346/828 2 | 3 | \documentclass{article} 4 | \usepackage{tikz} 5 | \usetikzlibrary{arrows} 6 | \usepackage[active,tightpage]{preview} 7 | \PreviewEnvironment{tikzpicture} 8 | 9 | \begin{document} 10 | \begin{tikzpicture}[->,node distance=2.5cm,auto,main node/.style={rectangle,rounded corners,draw,align=center}] 11 | 12 | \node [main node] (A) {$A$}; 13 | \node [main node] (D) [below left of=A] {$D$}; 14 | \node [main node] (B) [below of=D] {$B$}; 15 | \node [main node] (E) [below right of=A] {$E$}; 16 | \node [main node] (C) [below of=E] {$C$}; 17 | 18 | \path (A) edge node [left] {$d$} (D); 19 | \path (A) edge node [right] {$e$} (E); 20 | \path (D) edge node [right] {$b$} (B); 21 | \path (E) edge node [left] {$c$} (C); 22 | \path (B) edge [out=135,in=180] node [left] {$a$} (A); 23 | \path (C) edge [out=45,in=0] node [right] {$a$} (A); 24 | 25 | \end{tikzpicture} 26 | \end{document} -------------------------------------------------------------------------------- /booktabs_thick_line.tex: -------------------------------------------------------------------------------- 1 | \documentclass{scrartcl} 2 | \usepackage{booktabs} 3 | \usepackage[active,tightpage]{preview} 4 | \PreviewEnvironment{tabular} 5 | \begin{document} 6 | \begin{table} 7 | \centering 8 | \caption{Example} 9 | \begin{tabular}{rccc} 10 | \toprule 11 | Thing & Value & Value & Value\\ 12 | \midrule 13 | A & 1 & 2 & 3\\ 14 | B & 1 & 2 & 3\\ 15 | C & 1 & 2 & 3\\ 16 | \specialrule{2pt}{0.5pt}{0.5pt} 17 | D & 1 & 2 & 3\\ 18 | E & 1 & 2 & 3\\ 19 | \bottomrule 20 | \end{tabular} 21 | \label{tab:example} 22 | \end{table} 23 | \end{document} 24 | -------------------------------------------------------------------------------- /boxplot.tex: -------------------------------------------------------------------------------- 1 | % How to draw boxplots with TikZ. Adapted from 2 | % “fluffyk”s example in the LaTeX community forum: http://is.gd/cfSJai 3 | 4 | \documentclass{article} 5 | 6 | \usepackage{pgf} 7 | \usepackage{pgfplots} 8 | \usepackage[active,tightpage]{preview} 9 | \usetikzlibrary{fit,calc} 10 | \usepgfplotslibrary{external} 11 | \newcommand{\boxplot}[6]{% 12 | %#1: center, #2: median, #3: 1/4 quartile, #4: 3/4 quartile, #5: min, #6: max 13 | \filldraw[fill=white,line width=0.2mm] let \n{boxxl}={#1-0.1}, \n{boxxr}={#1+0.1} in (axis cs:\n{boxxl},#3) rectangle (axis cs:\n{boxxr},#4); % draw the box 14 | \draw[line width=0.2mm, color=red] let \n{boxxl}={#1-0.1}, \n{boxxr}={#1+0.1} in (axis cs:\n{boxxl},#2) -- (axis cs:\n{boxxr},#2); % median 15 | \draw[line width=0.2mm] (axis cs:#1,#4) -- (axis cs:#1,#6); % bar up 16 | \draw[line width=0.2mm] let \n{whiskerl}={#1-0.025}, \n{whiskerr}={#1+0.025} in (axis cs:\n{whiskerl},#6) -- (axis cs:\n{whiskerr},#6); % upper quartile 17 | \draw[line width=0.2mm] (axis cs:#1,#3) -- (axis cs:#1,#5); % bar down 18 | \draw[line width=0.2mm] let \n{whiskerl}={#1-0.025}, \n{whiskerr}={#1+0.025} in (axis cs:\n{whiskerl},#5) -- (axis cs:\n{whiskerr},#5); % lower quartile 19 | } 20 | 21 | \PreviewEnvironment{tikzpicture} 22 | 23 | \begin{document} 24 | \tikzset{external/remake next} 25 | \begin{tikzpicture} 26 | \begin{axis}[% 27 | xmin=0, xmax=6,% 28 | ymin=-.01, ymax=.4,% 29 | xtick={1,2,3,4,5},xticklabels={D04,D10,D21,D36,D60}% 30 | ] 31 | %#1: center, #2: median, #3: 1/4 quartile, #4: 3/4 quartile, #5: min, #6: max 32 | \boxplot{1}{.00479}{.001777}{.011400}{0.0000232}{.0209} 33 | \boxplot{2}{.00828}{.004987}{.018975}{0.0005100}{.1} 34 | \boxplot{3}{.03300}{.013950}{.088550}{0.0008580}{1.06} 35 | \boxplot{4}{.06708}{.034778}{.135850}{0.0060770}{5.08} 36 | \boxplot{5}{.06800}{.033600}{.152500}{0.0000030}{1.51} 37 | \end{axis} 38 | \end{tikzpicture} 39 | 40 | \end{document} 41 | -------------------------------------------------------------------------------- /changes-bug.tex: -------------------------------------------------------------------------------- 1 | % Document to show a bug with using Sébastien or Sebastien as author with the 2 | % changes package. Ran into this when tracking final changes of the acinus-paper 3 | % with the Co-authors. 4 | % Bug report submitted here: http://is.gd/P4kmf3 5 | 6 | \documentclass{article} 7 | \usepackage[utf8]{inputenc} 8 | \usepackage[T1]{fontenc} 9 | \usepackage{changes} 10 | 11 | % uncomment one of the three lines between "% --- %" and compile twice. 12 | % the second line (with S*é*bastien) breaks \listofchanges 13 | % --- % 14 | \definechangesauthor[name={Sebastien},color=red]{sb} 15 | %\definechangesauthor[name={Sébastien},color=red]{sb} 16 | %\definechangesauthor[name={Hägar},color=red]{sb} 17 | % --- % 18 | \definechangesauthor[name={Alice},color=green]{al} 19 | \definechangesauthor[name={Bob},color=blue]{bb} 20 | 21 | \title{Some title} 22 | \author{Sébastien \and Alice \and Bob} 23 | 24 | \begin{document} 25 | 26 | \maketitle 27 | 28 | \listofchanges 29 | 30 | Here is some \replaced[id=sb]{text}{thext}, which has \replaced[id=al]{three}{some} \added[id=bb]{orthographic and logical} changes. 31 | 32 | \end{document} -------------------------------------------------------------------------------- /chapterbib/README.md: -------------------------------------------------------------------------------- 1 | Small example to successfully have an individual reference list (based on *one* bibliography file) for each chapter. 2 | 3 | On a *NIX-based system you should be able to just do `bash compilationscript.bash` to compile the example and read the resulting PDF file. 4 | This runs `pdflatex` on the main file, calls `bibtex` for each of the chapter files and runs `pdflatex` several times afterwards. 5 | 6 | Or you can read the resulting [PDF](main.pdf) which is present in this sub folder. 7 | -------------------------------------------------------------------------------- /chapterbib/compilationscript.bash: -------------------------------------------------------------------------------- 1 | pdflatex main 2 | for i in `ls *.aux`; do bibtex $i; done 3 | pdflatex main 4 | pdflatex main 5 | -------------------------------------------------------------------------------- /chapterbib/discussion.tex: -------------------------------------------------------------------------------- 1 | %!TeX root = main.tex 2 | \chapter{Discussion} 3 | \lipsum[1] 4 | \cite{misc-full} 5 | \bibliographystyle{plainnat} 6 | \bibliography{xampl} -------------------------------------------------------------------------------- /chapterbib/introduction.tex: -------------------------------------------------------------------------------- 1 | %!TeX root = main.tex 2 | \chapter{Introduction} 3 | The document here uses the an example bibliography (\directory{/usr/share/texlive/texmf-dist/bibtex/bib/base/xampl.bib})\footnote{At least that's where the file is on Ubuntu 16.04}, based on \href{https://tex.stackexchange.com/a/57599/828}{this tex.SE} question to show how to make a bibliography for each chapter of a big document. 4 | 5 | To typeset it 6 | \begin{itemize} 7 | \item run \verb+pdflatex+ on the main file 8 | \item run \hologo{BibTeX} on each of the \verb+.aux+ files generated for each chapter. 9 | \item run \verb+pdflatex+ on the main file 10 | \item run \verb+pdflatex+ on the main file 11 | \end{itemize} 12 | 13 | You should achieve the same result with the tiny bash script below, which \verb+pdftex+es the main file a sufficient amount of times and calls \hologo{BibTeX} for each of the \verb+.aux+ files inbetween those calls. 14 | 15 | \lstinputlisting[language=bash]{compilationscript.bash} 16 | 17 | You can enter these commands one after one in your terminal, or just call \verb+bash compilationscript.bash+ in your terminal if you're using some kind of UNIX system. 18 | 19 | And here is a very important citation~\cite{article-full}, which is what this is all about\ldots 20 | \bibliographystyle{plainnat} 21 | \bibliography{xampl} 22 | -------------------------------------------------------------------------------- /chapterbib/main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/habi/latex/bee3ab77416c36bdb1b08fa420f11da8d0c76586/chapterbib/main.pdf -------------------------------------------------------------------------------- /chapterbib/main.tex: -------------------------------------------------------------------------------- 1 | \documentclass{report} 2 | \usepackage[T1]{fontenc} % for my name with umlaut 3 | \usepackage[utf8]{inputenc} % for my name with umlaut 4 | \usepackage[numbers,square,sectionbib]{natbib} % for the bibliography 5 | \usepackage{chapterbib} % for the bibliography 6 | \usepackage{lipsum} % for the dummy text 7 | \usepackage{hologo} % fot bibtex logo 8 | \usepackage{listings} % for code listing 9 | \usepackage{menukeys} % for file path 10 | \usepackage{hyperref} % for URLs 11 | 12 | \lstset{basicstyle=\footnotesize, 13 | breakatwhitespace=false, 14 | breaklines=true, 15 | numbers=left, 16 | numbersep=5pt, 17 | stepnumber=2, 18 | showspaces=true, 19 | title=\lstname, 20 | frame=single} 21 | 22 | \title{A self-contained \emph{chapterbib} example} 23 | \author{David Haberthür} 24 | \date{\today} 25 | 26 | \begin{document} 27 | \maketitle 28 | \include{introduction} 29 | \include{material} 30 | \include{results} 31 | \include{discussion} 32 | \end{document} -------------------------------------------------------------------------------- /chapterbib/material.tex: -------------------------------------------------------------------------------- 1 | %!TeX root = main.tex 2 | \chapter{Materials \& Methods} 3 | \lipsum[1] 4 | \cite{whole-journal} 5 | \bibliographystyle{plainnat} 6 | \bibliography{xampl} -------------------------------------------------------------------------------- /chapterbib/results.tex: -------------------------------------------------------------------------------- 1 | %!TeX root = main.tex 2 | \chapter{Results} 3 | \lipsum[1] 4 | \cite{proceedings-full} 5 | \bibliographystyle{plainnat} 6 | \bibliography{xampl} -------------------------------------------------------------------------------- /circles.tex: -------------------------------------------------------------------------------- 1 | % Basic TikZ-example, showing how to draw some circles 2 | 3 | \documentclass{article} 4 | \usepackage[pdftex,active,tightpage]{preview} 5 | \usepackage{tikz} 6 | \PreviewEnvironment{tikzpicture} 7 | \begin{document} 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | \begin{tikzpicture} 10 | \draw (0,0) circle (1); 11 | \draw [fill=lightgray] (0,0) circle (0.75); 12 | \draw [fill=gray] (0,0) circle (0.5); 13 | \draw [fill=darkgray] (0,0) circle (0.25); 14 | \draw [ultra thick,red] (0,0) circle (0.025); 15 | \draw [red,thick,->] (0,0) -- (1,0) node at (1,0) [black,right] {1}; 16 | \draw [red,thick,->] (0,0) -- (0,0.75) node at (0,1) [black,above] {0.75}; 17 | %\draw [red,thick,->] (0,0) -- (-0.5,0) node at (-1,0) [black,left] {0.5}; 18 | %\draw [red,thick,->] (0,0) -- (0,-0.25) node at (0,-1) [black,below] {0.25}; 19 | \end{tikzpicture} 20 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 | \end{document} 22 | -------------------------------------------------------------------------------- /clipping_image.tex: -------------------------------------------------------------------------------- 1 | % Answer for http://tex.stackexchange.com/a/193592/828 using http://commons.wikimedia.org/wiki/Frog#mediaviewer/File:Masked_tree_frog_head.JPG from Wikimedia 2 | 3 | \documentclass{article} 4 | 5 | \usepackage{graphicx} 6 | \usepackage{tikz} 7 | \usepackage{lipsum} 8 | \usepackage[active,tightpage]{preview} 9 | 10 | \PreviewEnvironment{tikzpicture} 11 | 12 | \newcommand{\imsize}{\linewidth} 13 | \newlength\imagewidth 14 | \newlength\imagescale 15 | 16 | \begin{document} 17 | 18 | \lipsum[1] 19 | 20 | \renewcommand{\imsize}{0.618\linewidth} 21 | \pgfmathsetlength{\imagewidth}{\textwidth}% 22 | \pgfmathsetlength{\imagescale}{\imagewidth/851}% 23 | \begin{figure}[htb] 24 | \begin{tikzpicture}[x=\imagescale,y=-\imagescale] 25 | \clip (851/2, 567/2) circle (567/2); 26 | \node[anchor=north west, inner sep=0pt, outer sep=0pt] at (0,0) {\includegraphics[width=\imagewidth]{Masked_tree_frog_head}}; 27 | \end{tikzpicture} 28 | \caption{My image} 29 | \end{figure} 30 | 31 | \lipsum[1] 32 | 33 | \end{document} 34 | -------------------------------------------------------------------------------- /code-listing.tex: -------------------------------------------------------------------------------- 1 | % Code listing example for http://tex.stackexchange.com/a/111362/828 2 | 3 | \documentclass[paper=a4,DIV=calc]{article} 4 | \usepackage[utf8]{inputenc} 5 | \usepackage{listings} 6 | \usepackage{color} 7 | \usepackage{blindtext} 8 | \usepackage{lipsum} 9 | 10 | \title{Code listings} 11 | \author{David Haberthür} 12 | 13 | \lstset{language=Matlab, 14 | keywords={break,case,catch,continue,else,elseif,end,for,function, 15 | global,if,otherwise,persistent,return,switch,try,while,ones,zeros}, 16 | float=hbp, 17 | basicstyle=\ttfamily\small, 18 | keywordstyle=\color{blue}, 19 | commentstyle=\color{red}, 20 | stringstyle=\color{green}, 21 | frame=single, 22 | numbers=left, 23 | numberstyle=\tiny, 24 | stepnumber=2, 25 | showspaces=true, 26 | showstringspaces=false} 27 | 28 | \begin{document} 29 | \maketitle 30 | 31 | \blindtext 32 | 33 | \begin{lstlisting}[language=Matlab, 34 | frame=single, 35 | caption=Some Matlab code, 36 | label=matlab] 37 | S = 55; % Value of the underlying 38 | ... 39 | V = 2.2147 %This is the value of our put option 40 | \end{lstlisting} 41 | 42 | Here is some text which is referring to listing~\ref{matlab}, which we will explain later. There is also a second example, which is shown in listing~\ref{python}. 43 | 44 | 45 | \lstinputlisting[lastline=10, 46 | language=Python, 47 | frame=single, 48 | caption=First ten lines of some Python code, 49 | label=python] 50 | {/afs/psi.ch/user/h/haberthuer/Dev/ComputeSNR.py} 51 | 52 | \blindtext 53 | 54 | \end{document} -------------------------------------------------------------------------------- /combine-pdfs.tex: -------------------------------------------------------------------------------- 1 | % Example on how to use `pdfpages` to combine multiple PDF documents. 2 | % My answer for http://tex.stackexchange.com/q/218215/828 3 | 4 | \documentclass{article} 5 | 6 | \usepackage{pdfpages} 7 | 8 | \title{Some kind of a notebook} 9 | \author{Martin} 10 | \date{\today} 11 | 12 | \begin{document} 13 | 14 | \maketitle 15 | 16 | Here is the introduction to \emph{some kind of notebook}. 17 | 18 | \includepdf{somefolder/file1.pdf} 19 | 20 | Here's maybe some text inbetween. 21 | 22 | \includepdf[pages={2-3}]{anotherfolder/onlyincludepartially.pdf} 23 | 24 | And here's some end-notes. 25 | 26 | \end{document} -------------------------------------------------------------------------------- /draw_a_scalebar.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | """ 3 | Script to generate nice scalebars on images with LaTeX and TikZ. 4 | Ported from https://github.com/habi/latex/blob/master/scalebar.m to Python 5 | 6 | The script needs an image and a pixel size as input, then either uses the full 7 | width of the image or a user-defined length (also as input) and calculates all 8 | the necessary values to generate a LaTeX-file as output. 9 | Said LaTeX-file is then compiled with "latexmk" so that - after running the 10 | script - you get an image_scalebar.tex for further editing and an 11 | image_scalebar.pdf as well as image_scalebar.png for use in a talk. 12 | """ 13 | 14 | from optparse import OptionParser 15 | import numpy as np 16 | import matplotlib.pyplot as plt 17 | import os 18 | import subprocess 19 | import sys 20 | 21 | # Use Pythons Optionparser to define and read the options, and also give some 22 | # help to the user 23 | parser = OptionParser() 24 | usage = "usage: %prog [options] arg" 25 | parser.add_option("-i", "--image", dest="Image", 26 | help="Location of the file you want to draw a scalebar on", 27 | metavar="path") 28 | parser.add_option("-p", "--pixelsize", dest="Pixelsize", 29 | type="float", 30 | help="Pixel/voxel size of the image (in micrometers)", 31 | metavar="1.48") 32 | parser.add_option("-l", "--length", dest="Scalebarlength", 33 | type="int", 34 | help="Length of the scale bar you will draw. Generally you " 35 | "know that two features are x pixels afar from each other, " 36 | "then you can use this length, e.g. the tips of your sample " 37 | " are 646 pixels apart...", 38 | metavar="648") 39 | parser.add_option("-f", "--fullscale", dest="fullscale", 40 | default=1, 41 | action="store_true", 42 | help="Use the full image for scaling, do not define a scale " 43 | " bar manually. Makes the '-l' entry obsolete") 44 | parser.add_option("-n", "--nocompile", dest="nocompile", 45 | default=0, 46 | action="store_true", 47 | help="Do not compile the .tex file at the end, just " 48 | "generate it") 49 | (options, args) = parser.parse_args() 50 | 51 | # Show help if no parameters are given 52 | if options.Image is None: 53 | parser.print_help() 54 | print("Example:") 55 | print("The command below makes a 500 um long scalebar on a 2D image",\ 56 | "'rec.png', which is 1024 x 1014 pixels big (with 2.8 um pixel ",\ 57 | "size):") 58 | print() 59 | print(sys.argv[0], "-i /sls/X02DA/data/e13960/test.jpg -p 2.8 -f") 60 | print() 61 | print("The command below makes a 500 um long scalebar on a test-image",\ 62 | "'3d.jpg' from which you know that two features are 2170 px apart ",\ 63 | "(650 nm px size). The script asks you to click the two points.") 64 | print() 65 | print(sys.argv[0], "-i /sls/X02DA/data/e13960/test.jpg -p 0.65 -l 2170") 66 | print() 67 | sys.exit(1) 68 | 69 | # Warn user if options are missing or something else is wrong 70 | if not os.path.exists(options.Image): 71 | print("I cannot find", options.Image, ", please try again.") 72 | sys.exit(1) 73 | 74 | if options.Pixelsize is None: 75 | print("You need to enter a pixel size! Please enter your command as this") 76 | print(" ".join(sys.argv), "-p some_micrometers") 77 | sys.exit(1) 78 | 79 | if options.Scalebarlength: 80 | # Set fullscale to False if user wants to define a length himself 81 | options.fullscale = False 82 | 83 | # Hey ho, let's go 84 | print(80 * "-") 85 | 86 | # Display image to user 87 | Image = plt.imread(options.Image) 88 | plt.imshow(Image) 89 | plt.axis('image') 90 | 91 | # Either let user choose a set length or use the full scale of the image 92 | if options.fullscale: 93 | print("Using full size of image (" +\ 94 | str(Image.shape[1]), "x",\ 95 | str(Image.shape[0]), "px @" + \ 96 | str(options.Pixelsize), "um) to calculate scalebar") 97 | StartPoint = [(0, Image.shape[0] / 2)] 98 | EndPoint = [(Image.shape[1], Image.shape[0] / 2)] 99 | else: 100 | print() 101 | print("Please click on two points", options.Scalebarlength, "px (@",\ 102 | options.Pixelsize, "um) apart, i.e. the length you chose will",\ 103 | "be", str(options.Scalebarlength * options.Pixelsize / 1000), "mm") 104 | print() 105 | plt.title(options.Image + "\nClick on start point of " + 106 | str(options.Scalebarlength) + " px long (" + 107 | str(options.Scalebarlength * options.Pixelsize / 1000) + 108 | " mm) line") 109 | StartPoint = plt.ginput(1) 110 | plt.plot(StartPoint[0][0], StartPoint[0][1], marker="o", color="g") 111 | plt.axis('image') 112 | plt.draw() 113 | plt.title(options.Image + "\nClick on end point of " + 114 | str(options.Scalebarlength) + " px long (" + 115 | str(options.Scalebarlength * options.Pixelsize / 1000) + 116 | " mm) line") 117 | plt.draw() 118 | EndPoint = plt.ginput(1) 119 | 120 | # Plot the length we are using to calculate 121 | StartPoint = StartPoint[0] 122 | EndPoint = EndPoint[0] 123 | line = [StartPoint, EndPoint] 124 | plt.plot(StartPoint[0], StartPoint[1], marker="o", color="g") 125 | plt.plot(EndPoint[0], EndPoint[1], marker="o", color="r") 126 | plt.plot([StartPoint[0], EndPoint[0]], [StartPoint[1], EndPoint[1]]) 127 | plt.axis('image') 128 | 129 | # Calculate the stuff we need for drawing a nice scalebar and update the figure 130 | if options.fullscale: 131 | options.Scalebarlength = Image.shape[1] 132 | plt.title(options.Image + "\nThis line is " + str(options.Scalebarlength) + 133 | " px long (" + 134 | str(options.Scalebarlength * options.Pixelsize / 1000) + " mm)") 135 | plt.draw() 136 | 137 | ItemLength = 100 # px 138 | SetScaleBarTo = 500 # um 139 | 140 | Scale = options.Scalebarlength * options.Pixelsize / 1000 141 | ChosenLength = np.hypot(StartPoint[0] - EndPoint[0], 142 | StartPoint[1] - EndPoint[1]) 143 | UnitLength = Scale / ChosenLength * ItemLength * 1000 144 | ScaleBarLength = ItemLength / UnitLength * SetScaleBarTo 145 | 146 | # Inform the user 147 | print("The chosen length of", int(round(ChosenLength)), "px corresponds to",\ 148 | Scale, "mm.") 149 | print("%s px are thus %0.3f um" % (ItemLength, UnitLength)) 150 | print("%0.3f px are thus %s um and" % (ScaleBarLength, SetScaleBarTo)) 151 | print("%0.3f px are thus 100 um" % (ScaleBarLength / (SetScaleBarTo / 100))) 152 | 153 | # Write LaTeX-file 154 | print(80 * "-") 155 | OutputFile = os.path.join(os.getcwd(), 156 | os.path.splitext(os.path.basename(options.Image)) 157 | [0] + "_scalebar.tex") 158 | print("writing LaTeX-code to", OutputFile) 159 | outputfile = open(OutputFile, "w") 160 | # PDF and PNG output as per http://tex.stackexchange.com/a/11880/828 161 | outputfile.write("\\documentclass[tikz]{standalone}\n") 162 | outputfile.write("\\usepackage{tikz}\t\t\t% for drawing everything\n") 163 | outputfile.write("\t\\usetikzlibrary{spy}\t% for zooming\n") 164 | outputfile.write("\\usepackage{siunitx}\t\t% for nice SI units\n") 165 | outputfile.write("\\usepackage{shadowtext}\t% for shadowed text on the scalebar\n") 166 | outputfile.write("\t\\shadowoffset{1pt}\t% ideally the same as on line 13...\n") 167 | outputfile.write("\t\\shadowcolor{green}\t% ideally the same as on line 13...\n") 168 | outputfile.write("\\newcommand{\imsize}{\linewidth}% default width of image\n") 169 | outputfile.write("\\newlength\imagewidth% needed for correct scalebar\n") 170 | outputfile.write("\\newlength\imagescale% needed for correct scalebar\n") 171 | outputfile.write("\\begin{document}%\n") 172 | outputfile.write("%----------\n") 173 | outputfile.write("\\tikzset{shadowed/.style={preaction={transform canvas={shift={(1pt,-1pt)}},draw=green, thick}}} % shadowed drawing https://tex.stackexchange.com/a/185853/828\n") 174 | outputfile.write("\pgfmathsetlength{\imagewidth}{\imsize}%\n") 175 | outputfile.write("\pgfmathsetlength{\imagescale}{\imagewidth/" + 176 | str(Image.shape[1]) + "}%\n") 177 | outputfile.write("\def\\x{" + str(int(round(Image.shape[1] * 0.618))) + 178 | "}% scalebar-x starting at golden ratio of image width of " + 179 | str(Image.shape[1]) + "px = " + 180 | str(int(round(Image.shape[1] * 0.618))) + "\n") 181 | outputfile.write("\def\y{" + str(int(round(Image.shape[0] * 0.9))) + 182 | "}% scalebar-y at 90% of image height of " + 183 | str(Image.shape[0]) + "px = " + 184 | str(int(round(Image.shape[0] * 0.9))) + "\n") 185 | outputfile.write("\def\mag{4}% magnification of inset\n") 186 | outputfile.write("\def\size{75}% size of inset\n") 187 | outputfile.write("\\begin{tikzpicture}[x=\imagescale,y=-\imagescale,spy " + 188 | "using outlines={rectangle,magnification=\mag," + 189 | "size=\size,connect spies}]\n") 190 | outputfile.write("\t\\begin{scope}\n") 191 | outputfile.write("\t\t\clip (0,0) rectangle (" + str(Image.shape[1]) + "," + 192 | str(Image.shape[0]) + ");\n") 193 | outputfile.write("\t\t%\clip (" + str(Image.shape[1]/2) + "," + 194 | str(Image.shape[0] / 2) + ") circle (" + 195 | str(Image.shape[0] / 2) + ");\n") 196 | outputfile.write("\t\t\\node[anchor=north west, inner sep=0pt, outer " + 197 | "sep=0pt] at (0,0) {\includegraphics[width=\imagewidth]{" + 198 | str(os.path.join(os.path.split(os.path.abspath( 199 | options.Image))[0], '{{' + 200 | os.path.splitext(os.path.basename(options.Image))[0]) + 201 | '}}') + "}};\n") 202 | outputfile.write("\t\\end{scope}\n") 203 | outputfile.write("\t%\spy [red] on (" + str(Image.shape[1] - 300) + "," + 204 | str(Image.shape[0] - 300) + 205 | ") in node at (0,0) [anchor=north west];\n") 206 | outputfile.write("\t% " + "%0.3f" % ChosenLength + "px = " + 207 | str(Scale) + "mm -> " + str(ItemLength) + "px = " + 208 | "%0.3f" % UnitLength + "um -> " + 209 | "%0.3f" % ScaleBarLength + "px = " + 210 | str(SetScaleBarTo) + "um, " + 211 | "%0.3f" % (ScaleBarLength / (SetScaleBarTo / 100)) + 212 | "px = 100um\n") 213 | outputfile.write("\t%\draw[|-|,blue,thick] (" + 214 | str(int(round(StartPoint[0]))) + "," + 215 | str(int(round(StartPoint[1]))) + ") -- (" + 216 | str(int(round(EndPoint[0]))) + "," + 217 | str(int(round(EndPoint[1]))) + ") node [sloped,midway," + 218 | "above,fill=white,semitransparent,text opacity=1] {\SI{" + 219 | str(Scale) + "}{\milli\meter} (" + 220 | str(int(round(ChosenLength))) + "px) TEMPORARY!};\n") 221 | outputfile.write("\t\draw[|-|,white,thick,shadowed] (\\x,\y) -- (\\x+%0.3f" % ScaleBarLength + 222 | ",\y) node [midway,above]" + 223 | " {\shadowtext{\SI{" + str(SetScaleBarTo) + "}{\micro\meter}}};\n") 224 | outputfile.write("\t%\draw[color=red, anchor=south west] (0," + 225 | str(int(round(Image.shape[0]))) + ") node [fill=white, " + 226 | "semitransparent] {Legend} node {Legend};\n") 227 | outputfile.write("\end{tikzpicture}%\n") 228 | outputfile.write("%----------\n") 229 | outputfile.write("\end{document}%\n") 230 | outputfile.close() 231 | 232 | # Show/Update figure 233 | plt.pause(0.001) 234 | plt.draw() 235 | 236 | print(80 * "-") 237 | if options.nocompile: 238 | # Inform the user what has been going on and make sure we show image 239 | print("You now have a tex file (" + OutputFile + " for further editing") 240 | else: 241 | # Compile LaTeX-file and cleanup afterwards 242 | nirvana = open(os.devnull, "w") 243 | print("compiling", OutputFile) 244 | # Compile file with latexmk. 245 | # This gives us a .PNG, .PDF and an error message, which we disregard 246 | subprocess.call(['latexmk', '-pdf', '-f', '-silent', 247 | '-latexoption=--shell-escape', OutputFile], stdout=nirvana) 248 | # cleanup after compilation 249 | print("cleaning up") 250 | subprocess.call(['latexmk', '-c', OutputFile], stdout=nirvana) 251 | nirvana.close() 252 | # Inform the user what has been going on 253 | print("You now have three files (" + OutputFile + " and .../" +\ 254 | os.path.basename(OutputFile)[:-3] + "pdf and .png).") 255 | print("The .tex-file is for further editing and the two other files can be "\ 256 | "used as is in a PowerPoint or Keynote slide...") 257 | 258 | # Keep the figure open 259 | plt.show() 260 | -------------------------------------------------------------------------------- /embedded_movie.tex: -------------------------------------------------------------------------------- 1 | % Show a movie in the PDF. Needs 'movie.avi', which is also in the repo 2 | 3 | \documentclass[paper=a4]{scrartcl} 4 | 5 | \usepackage[utf8]{inputenc} 6 | \usepackage{movie15} % needed for the inclusion of the movie 7 | \usepackage{hyperref} % prerequisite for 'movie15' 8 | 9 | \title{Movie-Example} 10 | \author{David Haberthür} 11 | 12 | \begin{document} 13 | \maketitle 14 | \begin{figure}[htb]% 15 | \centering% 16 | \includemovie[autoplay,text=movie.avi]% parameters for movie15 17 | {.5\linewidth}{.5\linewidth}% height and width for display of the movie 18 | {movie.avi}% actual movie-file 19 | \caption{Rotating vertebrae}% 20 | \label{mov:vertebrae}% 21 | \end{figure}% 22 | \end{document} 23 | -------------------------------------------------------------------------------- /enclosing-some-points.tex: -------------------------------------------------------------------------------- 1 | % basic example using the fitting library. 2 | % made for http://tex.stackexchange.com/a/114625/828 3 | % updated after seeing http://tex.stackexchange.com/a/114687/828 4 | 5 | \documentclass{article} 6 | \usepackage{tikz} 7 | \usetikzlibrary{fit} 8 | \usepackage[active,tightpage]{preview} 9 | \PreviewEnvironment{tikzpicture} 10 | 11 | \begin{document} 12 | \begin{tikzpicture}[every fit/.style={red,dashed,rounded corners,draw}] 13 | % Points and connecting arrows 14 | %% Level A 15 | \node at (3,8) (a) {\(\bullet\)}; 16 | 17 | %%Level B 18 | \node at (1.75,6) (b1) {\(\bullet\)}; 19 | \node at (4.25,6) (b2) {\(\bullet\)}; 20 | \draw (a) -- (b1); 21 | \draw (a) -- (b2); 22 | 23 | %% Level C 24 | \node at (1,4) (c1) {\(\bullet\)}; 25 | \node at (3,4) (c2) {\(\bullet\)}; 26 | \node at (5,4) (c3) {\(\bullet\)}; 27 | \draw (b1) -- (c1); 28 | \draw (b1) -- (c2); 29 | \draw [double=black,draw=white] (b2) -- (c1); 30 | \draw (b2) -- (c3); 31 | 32 | %% Level D 33 | \node at (0,1.5) (d1) {\(\bullet\)}; 34 | \node at (1,2) (d2) {\(\bullet\)}; 35 | \node at (2,2) (d3) {\(\bullet\)}; 36 | \node at (4,1.5) (d4) {\(\bullet\)}; 37 | \node at (4,2.5) (d5) {\(\bullet\)}; 38 | \node at (6,2) (d6) {\(\bullet\)}; 39 | \draw (c1) -- (d1); 40 | \draw (c2) -- (d2); 41 | \draw (c2) -- (d3); 42 | \draw (c2) -- (d4); 43 | \draw (c3) -- (d5); 44 | \draw (c3) -- (d6); 45 | \draw [double=black,draw=white] (b2) to [out=-120, in=60] (d1); 46 | 47 | % Fitting and labels of groups 48 | \node [fit=(a),label=0:A] {}; 49 | \node [fit=(b1) (b2),label=0:B] {}; 50 | \node [fit=(c1) (c3),label=0:C] (C) {}; 51 | \node [fit=(d1) (d4) (d5) (d6),label=0:D] (D) {}; 52 | 53 | % Rest 54 | \draw [->] (6,5) -- (8,5) node [midway,above] {\(\theta\)}; 55 | \node at (9,8) (e) {\(\bullet\)}; 56 | \node at (9,6) (f) {\(\bullet\)}; 57 | \node at (9,4) (g) {\(\bullet\)}; 58 | \node at (9,2) (h) {\(\bullet\)}; 59 | \draw [->] (e) -- (f) -- (g) -- (h); 60 | \end{tikzpicture} 61 | \end{document} 62 | -------------------------------------------------------------------------------- /filesize_test.tex: -------------------------------------------------------------------------------- 1 | % Proof that file size does not increase with increased numbers of included files. 2 | % Compile with `pfdLaTeX`. 3 | % I did not know that it does not when you include the same file:http://tex.stackexchange.com/a/139405/828 4 | % The file we include is 25 K according to "ls -lh *.jpg" 5 | % Use the command below to keep an eye on the file size while uncommenting environments 6 | % watch -n 2 "ls -lh file*.pdf" 7 | % figenv pg Filesize 8 | % lipsum 2 44K 9 | % 1 3 69K 10 | % 2 4 69K 11 | % 3 5 70K 12 | % 4 6 70K 13 | % 5 7 70K 14 | % 6 8 70K 15 | % 8 10 73K 16 | % 9 11 74K 17 | % 10 12 74K 18 | % So, while the file *does* grow, it does not scales linearly with the number of inclusions. Cool! 19 | \documentclass{article} 20 | \usepackage[utf8]{inputenc} 21 | \usepackage[T1]{fontenc} 22 | \usepackage{graphicx} 23 | \usepackage{lipsum} 24 | 25 | \title{Size test} 26 | \author{David Haberthür} 27 | \date{\today} 28 | 29 | \begin{document} 30 | \maketitle 31 | 32 | \lipsum 33 | \clearpage 34 | 35 | \begin{figure} 36 | \centering 37 | \includegraphics[width=0.618\linewidth]{scalebarimage} 38 | \caption{1} 39 | \end{figure} 40 | \clearpage 41 | 42 | \begin{figure} 43 | \centering 44 | \includegraphics[width=0.618\linewidth]{scalebarimage} 45 | \caption{2} 46 | \end{figure} 47 | \clearpage 48 | 49 | \begin{figure} 50 | \centering 51 | \includegraphics[width=0.618\linewidth]{scalebarimage} 52 | \caption{3} 53 | \end{figure} 54 | \clearpage 55 | 56 | \begin{figure} 57 | \centering 58 | \includegraphics[width=0.618\linewidth]{scalebarimage} 59 | \caption{4} 60 | \end{figure} 61 | \clearpage 62 | 63 | \begin{figure} 64 | \centering 65 | \includegraphics[width=0.618\linewidth]{scalebarimage} 66 | \caption{5} 67 | \end{figure} 68 | \clearpage 69 | 70 | \begin{figure} 71 | \centering 72 | \includegraphics[width=0.618\linewidth]{scalebarimage} 73 | \caption{6} 74 | \end{figure} 75 | \clearpage 76 | 77 | \begin{figure} 78 | \centering 79 | \includegraphics[width=0.618\linewidth]{scalebarimage} 80 | \caption{7} 81 | \end{figure} 82 | \clearpage 83 | 84 | \begin{figure} 85 | \centering 86 | \includegraphics[width=0.618\linewidth]{scalebarimage} 87 | \caption{8} 88 | \end{figure} 89 | \clearpage 90 | 91 | \begin{figure} 92 | \centering 93 | \includegraphics[width=0.618\linewidth]{scalebarimage} 94 | \caption{9} 95 | \end{figure} 96 | \clearpage 97 | 98 | \begin{figure} 99 | \centering 100 | \includegraphics[width=0.618\linewidth]{scalebarimage} 101 | \caption{10} 102 | \end{figure} 103 | \clearpage 104 | 105 | \end{document} -------------------------------------------------------------------------------- /formulas.tex: -------------------------------------------------------------------------------- 1 | % Answer for http://tex.stackexchange.com/q/147159/828 2 | % Basically just reformatting the code given in the answer, and nice-ying it 3 | % up a bit. 4 | \documentclass[paper=a4]{scrartcl} 5 | 6 | \usepackage[T1]{fontenc} 7 | \usepackage[utf8]{inputenc} 8 | \usepackage{booktabs} 9 | \usepackage{amsmath} 10 | 11 | \title{Calcul théorique de la propulsion éléctromagnetique de l'aimant} 12 | \author{Lawrence} 13 | 14 | \begin{document} 15 | \maketitle 16 | 17 | \section*{Constantes ``modifiables''} 18 | \begin{table}[h] 19 | \begin{tabular}{lc} 20 | \toprule 21 | Rayon des spires & \(D\)\\ 22 | Nombre de spire & \(N\)\\ 23 | Tension du générateur & \(\mu\)\\ 24 | Capacité du condensateur & \(C\)\\ 25 | Arètes du tore & \(L\)\\ 26 | Masse du tore & \(m\)\\ 27 | \bottomrule 28 | \end{tabular} 29 | \end{table} 30 | 31 | \section*{Variables} 32 | \begin{table}[h] 33 | \begin{tabular}{lc} 34 | \toprule 35 | Vitesse de tore & \(v(t)\)\\ 36 | Tension du condensateur & \(u(t)\)\\ 37 | Intensité & \(i(t)\)\\ 38 | Champ magnétique & \(\vec{B}\)\\ 39 | Potentiel vecteur & \(\vec{A}\)\\ 40 | Densité de courant dans le tore & \(\vec{j}\)\\ 41 | \bottomrule 42 | \end{tabular} 43 | \end{table} 44 | 45 | \section*{Equations} 46 | \begin{equation} 47 | \boxed{ 48 | m \frac{dv}{dt} = -mg + \iiint_{ 49 | \textrm{tore-en-mouvement}} (\vec{j} \times \vec{B}) \cdot \vec{e_z 50 | }d\tau 51 | } 52 | \label{m} 53 | \end{equation} 54 | 55 | \begin{equation} 56 | i = -C \frac{du}{dt} 57 | \label{i} 58 | \end{equation} 59 | 60 | \begin{equation} 61 | u = Ri + \iint_{N-spires} \vec{B} \cdot d\vec{S} 62 | \label{u} 63 | \end{equation} 64 | 65 | \begin{equation} 66 | \vec{j} = \gamma \left( 67 | \vec{v} \times \vec{B} - \frac{\partial\vec{A}}{\partial t} 68 | \right) 69 | \label{j} 70 | \end{equation} 71 | 72 | \begin{equation} 73 | \vec{A} = \frac{\mu_0}{4\pi} \iiint_{tore-en-mouvement} \frac{\vec{j}}{PM} 74 | \cdot d\tau + \frac{\mu_0 Ni}{4\pi} \int\frac{d\vec{r}}{PM} 75 | \label{A} 76 | \end{equation} 77 | 78 | \begin{equation} 79 | \vec{B} = rot\vec{A} 80 | \label{B} 81 | \end{equation} 82 | 83 | \end{document} 84 | -------------------------------------------------------------------------------- /fourier_series_expansion.m: -------------------------------------------------------------------------------- 1 | T=0.3; 2 | A=0.3; 3 | t=0:0.01:4*T; 4 | n1=length(t); 5 | N=100; 6 | s=0; 7 | 8 | signal=0; 9 | for i=1:n1 10 | s=0; 11 | for n=1:N 12 | s=s+A*4/(pi*(2*n-1))*sin(2*pi*(2*n-1)/T*t(i)); 13 | end 14 | signal(i)=s; 15 | end 16 | plot(t,signal); 17 | 18 | matlab2tikz() -------------------------------------------------------------------------------- /fourier_series_expansion.tex: -------------------------------------------------------------------------------- 1 | \documentclass{article} 2 | \usepackage{tikz,pgfplots} 3 | \usepackage[active,tightpage]{preview} 4 | \PreviewEnvironment{tikzpicture} 5 | \begin{document} 6 | 7 | \begin{tikzpicture} 8 | \begin{axis} 9 | \addplot [color=blue,solid] 10 | table[row sep=crcr]{ 11 | 0 0\\ 12 | 0.01 0.302387144957655\\ 13 | 0.02 0.301150753370238\\ 14 | 0.03 0.298375570984069\\ 15 | 0.04 0.300647458957776\\ 16 | 0.05 0.300548549766943\\ 17 | 0.06 0.298995957934019\\ 18 | 0.07 0.300480519514177\\ 19 | 0.08 0.300480519514176\\ 20 | 0.09 0.29899595793402\\ 21 | 0.1 0.300548549766943\\ 22 | 0.11 0.300647458957775\\ 23 | 0.12 0.298375570984069\\ 24 | 0.13 0.301150753370238\\ 25 | 0.14 0.302387144957655\\ 26 | 0.15 3.77542115127404e-15\\ 27 | 0.16 -0.302387144957655\\ 28 | 0.17 -0.301150753370238\\ 29 | 0.18 -0.298375570984069\\ 30 | 0.19 -0.300647458957775\\ 31 | 0.2 -0.300548549766942\\ 32 | 0.21 -0.298995957934019\\ 33 | 0.22 -0.300480519514176\\ 34 | 0.23 -0.300480519514176\\ 35 | 0.24 -0.29899595793402\\ 36 | 0.25 -0.300548549766943\\ 37 | 0.26 -0.300647458957776\\ 38 | 0.27 -0.298375570984068\\ 39 | 0.28 -0.301150753370237\\ 40 | 0.29 -0.302387144957655\\ 41 | 0.3 -7.55084230254808e-15\\ 42 | 0.31 0.302387144957654\\ 43 | 0.32 0.301150753370237\\ 44 | 0.33 0.29837557098407\\ 45 | 0.34 0.300647458957777\\ 46 | 0.35 0.300548549766944\\ 47 | 0.36 0.298995957934018\\ 48 | 0.37 0.300480519514177\\ 49 | 0.38 0.300480519514174\\ 50 | 0.39 0.298995957934022\\ 51 | 0.4 0.300548549766944\\ 52 | 0.41 0.300647458957777\\ 53 | 0.42 0.298375570984067\\ 54 | 0.43 0.301150753370237\\ 55 | 0.44 0.302387144957654\\ 56 | 0.45 -8.18728593532897e-15\\ 57 | 0.46 -0.302387144957655\\ 58 | 0.47 -0.301150753370238\\ 59 | 0.48 -0.298375570984068\\ 60 | 0.49 -0.300647458957778\\ 61 | 0.5 -0.300548549766943\\ 62 | 0.51 -0.298995957934016\\ 63 | 0.52 -0.300480519514178\\ 64 | 0.53 -0.300480519514179\\ 65 | 0.54 -0.29899595793402\\ 66 | 0.55 -0.300548549766945\\ 67 | 0.56 -0.300647458957773\\ 68 | 0.57 -0.298375570984064\\ 69 | 0.58 -0.301150753370239\\ 70 | 0.59 -0.302387144957652\\ 71 | 0.6 -1.51016846050962e-14\\ 72 | 0.61 0.302387144957655\\ 73 | 0.62 0.301150753370239\\ 74 | 0.63 0.298375570984065\\ 75 | 0.64 0.300647458957779\\ 76 | 0.65 0.300548549766947\\ 77 | 0.66 0.298995957934013\\ 78 | 0.67 0.300480519514179\\ 79 | 0.68 0.300480519514178\\ 80 | 0.69 0.298995957934022\\ 81 | 0.7 0.300548549766941\\ 82 | 0.71 0.300647458957774\\ 83 | 0.72 0.298375570984066\\ 84 | 0.73 0.301150753370235\\ 85 | 0.74 0.302387144957653\\ 86 | 0.75 -3.68337151806705e-15\\ 87 | 0.76 -0.302387144957655\\ 88 | 0.77 -0.301150753370235\\ 89 | 0.78 -0.298375570984065\\ 90 | 0.79 -0.300647458957776\\ 91 | 0.8 -0.30054854976694\\ 92 | 0.81 -0.298995957934016\\ 93 | 0.82 -0.300480519514178\\ 94 | 0.83 -0.300480519514175\\ 95 | 0.84 -0.298995957934021\\ 96 | 0.85 -0.300548549766944\\ 97 | 0.86 -0.300647458957778\\ 98 | 0.87 -0.298375570984064\\ 99 | 0.88 -0.301150753370239\\ 100 | 0.89 -0.302387144957646\\ 101 | 0.9 -7.08452764472111e-14\\ 102 | 0.91 0.302387144957655\\ 103 | 0.92 0.301150753370237\\ 104 | 0.93 0.298375570984071\\ 105 | 0.94 0.300647458957776\\ 106 | 0.95 0.300548549766945\\ 107 | 0.96 0.298995957934014\\ 108 | 0.97 0.300480519514176\\ 109 | 0.98 0.300480519514172\\ 110 | 0.99 0.298995957934027\\ 111 | 1 0.300548549766942\\ 112 | 1.01 0.300647458957771\\ 113 | 1.02 0.298375570984071\\ 114 | 1.03 0.301150753370237\\ 115 | 1.04 0.302387144957656\\ 116 | 1.05 -3.7046597480602e-14\\ 117 | 1.06 -0.302387144957659\\ 118 | 1.07 -0.301150753370238\\ 119 | 1.08 -0.29837557098407\\ 120 | 1.09 -0.30064745895778\\ 121 | 1.1 -0.300548549766942\\ 122 | 1.11 -0.298995957934014\\ 123 | 1.12 -0.300480519514181\\ 124 | 1.13 -0.300480519514172\\ 125 | 1.14 -0.298995957934024\\ 126 | 1.15 -0.300548549766942\\ 127 | 1.16 -0.300647458957776\\ 128 | 1.17 -0.298375570984067\\ 129 | 1.18 -0.301150753370239\\ 130 | 1.19 -0.302387144957663\\ 131 | 1.2 -3.02033692101923e-14\\ 132 | }; 133 | \end{axis} 134 | \end{tikzpicture} 135 | 136 | \end{document} -------------------------------------------------------------------------------- /full_page_pdf.tex: -------------------------------------------------------------------------------- 1 | % Use the preview package to generate "full-page" images, i.e. crop to the 2 | % relevant parts of the figure 3 | 4 | \documentclass{article} 5 | \usepackage[pdftex,active,tightpage]{preview} 6 | %\setlength\PreviewBorder{2mm} % use to add a border around the image 7 | \usepackage{tikz} 8 | \begin{document} 9 | \begin{preview} 10 | % Put everything you want inbetween \begin{preview} and \end{preview} or use 11 | % \PreviewEnvironment{tikzpicture} in the preamble to only have the TikZ- 12 | % picture in the output 13 | \begin{tikzpicture} 14 | \shade (0,0) circle(2); % background 15 | \draw (0,0) circle(2); % rim 16 | \draw (.75,1) circle(.5); % right eye 17 | \fill (.66,.9) circle(.25); % right pupil 18 | \draw (-.75,1) circle(.5); % left eye 19 | \fill (-.66,.9) circle(.25);% left pupil 20 | \fill (.2,0) circle (.1); % right nostril 21 | \fill (-.2,0) circle (.1); % left nostril 22 | \draw (-135:1) arc (-135:-45:1) -- cycle; % mouth 23 | \end{tikzpicture} 24 | \end{preview} 25 | \end{document} 26 | -------------------------------------------------------------------------------- /headers.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt]{report} % to have chapters 2 | 3 | \usepackage{fancyhdr} % to change header and footers 4 | \usepackage{blindtext} % to quickly get a full document 5 | \usepackage{times} 6 | 7 | \title{Some document with redefined footer on every page} 8 | \author{David Haberth\"ur} 9 | 10 | \pagestyle{fancy} % Turn on the style 11 | \fancyhf{} % Start with clearing everything in the header and footer 12 | % Set the right side of the footer to be the page number 13 | \fancyfoot[R]{\thepage} 14 | 15 | % Redefine plain style, which is used for titlepage and chapter beginnings 16 | % From http://tex.stackexchange.com/a/30230/828 17 | \fancypagestyle{plain}{% 18 | \renewcommand{\headrulewidth}{0pt}% 19 | \fancyhf{}% 20 | \fancyfoot[R]{\thepage}% 21 | } 22 | 23 | \usepackage{titlesec} 24 | %\titleformat{\section}{\large\bfseries}{\thesection}{1em}{} 25 | \titleformat{\chapter}{\Large\bfseries}{\thechapter}{1em}{} 26 | \begin{document} 27 | \maketitle 28 | % Input some blind text 29 | \blinddocument 30 | \end{document} -------------------------------------------------------------------------------- /highlight-region-in-pgf-plot.tex: -------------------------------------------------------------------------------- 1 | % Code to highlight regions in a pgf plot, as shown in Figure 3.1. of my [https://github.com/habi/PhD-Thesis](PhD-Thesis). 2 | % For http://tex.stackexchange.com/a/156364/828 3 | 4 | \documentclass{article} 5 | \usepackage{pgfplots} 6 | \usepackage[graphics,tightpage,active]{preview} 7 | 8 | \PreviewEnvironment{tikzpicture} 9 | 10 | \begin{document} 11 | 12 | \begin{tikzpicture} 13 | \begin{axis}[% 14 | ymin=-1,% 15 | ymax=1,% 16 | grid=both,% 17 | ] 18 | \addplot [draw=red,fill=red, semitransparent] 19 | coordinates {(55,-1.1) (55,1.1) (333,1.1) (333,-1.1)}; 20 | \addplot [draw=green,fill=green, semitransparent] 21 | coordinates {(-360,-1.1) (-360,1.1) (55,1.1) (55,-1.1)}; 22 | \addplot[domain=-360:360, blue , very thick, smooth]{sin(x)}; 23 | \end{axis} 24 | \end{tikzpicture} 25 | 26 | \end{document} -------------------------------------------------------------------------------- /image_on_image.tex: -------------------------------------------------------------------------------- 1 | % Answer for http://tex.stackexchange.com/q/245691/828 2 | \documentclass{article} 3 | \usepackage{graphicx} 4 | \usepackage{tikz} 5 | 6 | \newlength\imagewidth 7 | \newlength\imagescale 8 | 9 | \begin{document} 10 | 11 | \begin{figure} 12 | \centering 13 | \includegraphics[width=0.618\linewidth]{img1} 14 | \caption{image 1} 15 | \end{figure} 16 | 17 | \begin{figure} 18 | \centering 19 | \includegraphics[width=0.309\linewidth]{img2} 20 | \caption{image 2} 21 | \end{figure} 22 | 23 | \begin{figure} 24 | \centering 25 | \pgfmathsetlength{\imagewidth}{\linewidth}% 26 | \pgfmathsetlength{\imagescale}{\imagewidth/524}% 27 | \begin{tikzpicture}[x=\imagescale,y=-\imagescale] 28 | \node[anchor=north west] at (0,0) {\includegraphics[width=\imagewidth]{img1}}; 29 | \node[anchor=north west] at (300,100) {\includegraphics[width=0.25\imagewidth]{img2}}; 30 | \end{tikzpicture} 31 | \caption{Both images on top of each other} 32 | \end{figure} 33 | 34 | \end{document} 35 | -------------------------------------------------------------------------------- /img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/habi/latex/bee3ab77416c36bdb1b08fa420f11da8d0c76586/img1.png -------------------------------------------------------------------------------- /img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/habi/latex/bee3ab77416c36bdb1b08fa420f11da8d0c76586/img2.png -------------------------------------------------------------------------------- /labels.tex: -------------------------------------------------------------------------------- 1 | % Example for http://tex.stackexchange.com/a/133599/828 2 | % based on 'texdoc labels' 3 | \documentclass[10pt]{article} 4 | \usepackage{labels} 5 | \LabelCols=3% Number of columns of labels per page 6 | \LabelRows=7% Number of rows of labels per page 7 | \LeftBorder=1mm% Space added to left border of each label 8 | \RightBorder=1mm% Space added to right border of each label 9 | \TopBorder=1mm% Space to leave at top of sheet 10 | \BottomBorder=1mm% Space to leave at bottom of sheet 11 | 12 | \begin{document} 13 | 14 | \begin{labels} 15 | Here is the first label 16 | 17 | Here is another, separated by an empty line 18 | 19 | Here is the third label 20 | 21 | This label should be on the next line, because we specified a \(3\times7\) layout. 22 | 23 | This label is very very long, and should thus wrap in the space alloted to one label. We can also introduce linebreaks \\ by adding \verb+\\+ somewhere. 24 | 25 | Here's the next label 26 | 27 | Here's the last label, because it's now time to stop 28 | \end{labels} 29 | 30 | \end{document} -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | ## Makefile based on https://github.com/kjhealy/pandoc-templates/blob/master/examples/starting_from_markdown/Makefile 2 | 3 | ## Define standard Markdown extension 4 | MEXT = md 5 | 6 | ## All markdown files in the working directory 7 | SRC = $(wildcard *.$(MEXT)) 8 | 9 | ## Bibliography 10 | BIB = /home/habi/P/Documents/library.bib 11 | 12 | ## Pandoc options to use 13 | OPTIONS = markdown+simple_tables+table_captions+yaml_metadata_block+smart 14 | 15 | ## Get last commit hash 16 | ID := $(shell git rev-parse --short HEAD) 17 | 18 | ## File names 19 | PDFS=$(SRC:.md=.$(ID).pdf) 20 | HTML=$(SRC:.md=.$(ID).html) 21 | TEX=$(SRC:.md=.$(ID).tex) 22 | DOCX=$(SRC:.md=.$(ID).docx) 23 | 24 | ## Targets 25 | all: $(PDFS) $(HTML) $(TEX) $(DOC) 26 | 27 | pdf: $(PDFS) 28 | html: $(HTML) 29 | tex: $(TEX) 30 | doc: $(DOCX) 31 | 32 | %.$(ID).html: %.md 33 | pandoc -r $(OPTIONS) -w html5 -s --bibliography=$(BIB) -o $@ $< 34 | 35 | %.$(ID).tex: %.md 36 | pandoc -r $(OPTIONS) -w latex -s --bibliography=$(BIB) -o $@ $< 37 | 38 | %.$(ID).pdf: %.md 39 | pandoc -r $(OPTIONS) --bibliography=$(BIB) -o $@ $< 40 | 41 | %.$(ID).docx: %.md 42 | pandoc -r $(OPTIONS) --bibliography=$(BIB) -o $@ $< 43 | 44 | clean: 45 | rm *.html *.pdf *.tex *.docx 46 | -------------------------------------------------------------------------------- /minimal.tex: -------------------------------------------------------------------------------- 1 | % My general-use, \LaTeX document, from which I generally start off 2 | \documentclass[paper=a4,twoside=true,DIV=calc]{scrartcl} 3 | \usepackage[utf8]{inputenc} % let me write my name properly 4 | \usepackage{lmodern} % use Latin Modern Family of Fonts 5 | \usepackage[T1]{fontenc} % properly encode western European fonts 6 | \usepackage{microtype} % refine typography 7 | \usepackage[automark]{scrlayer-scrpage} % use this instead of deprecated fancyhdr 8 | \usepackage[english]{babel} % make language switching easy 9 | \usepackage[backend=biber, natbib=true, backref=true, url=false]{biblatex} % modern bibliography 10 | \addbibresource{/afs/psi.ch/user/h/haberthuer/Documents/library.bib} % from this file kept organized in Mendeley 11 | \usepackage{graphicx} % we generally have figures 12 | \usepackage{subfig} % and subfigures 13 | \usepackage[detect-all=true,list-units=single,binary-units=true]{siunitx} % use SI units 14 | \usepackage{textcomp} % Get rid of warning if using \micro with siunitx, as per http://tex.stackexchange.com/a/74673/828 15 | \usepackage{booktabs} % nice tables 16 | \usepackage{todonotes} % mark stuff do to later with \todo{stuff\ldots} 17 | \usepackage{tikz} % we like to draw 18 | \usepackage{pgfplots} % we like nice plots 19 | \pgfplotsset{compat=newest} 20 | \usepgfplotslibrary{colorbrewer} % with proper colors 21 | \usepackage[markifdirty, markifdraft]{gitinfo2} % use git information 22 | \usepackage{csquotes} % make quoting stuff easy 23 | \usepackage{listings} % use nice listings 24 | \usepackage{sidenotes} % we prefer side- to footnotes 25 | \usepackage{blindtext} % we don't use 'blindtext' in general, but it makes *this* document look nice 26 | \usepackage[colorlinks=true]{hyperref} % (colored) links in documents are nice 27 | 28 | % Git stuff 29 | \renewcommand{\gitMark}{\gitBranch @\gitAbbrevHash\ committed on \gitAuthorIsoDate} % note at page bottom if document is dirty or in draft mode 30 | \ifoot{Version \gitAbbrevHash} % Git hash in inner footer from scrlayer-scrpage 31 | 32 | % Helpers 33 | \newcommand{\imsize}{\linewidth} % general figure size 34 | \newcommand{\subfigureautorefname}{\figureautorefname} % make it possible to use \autoref{label} with subfigures 35 | \newcommand{\ie}{i.e.\ } % simplify often used abbreviation 36 | \newcommand{\eg}{e.g.\ } 37 | 38 | % Scalebar stuff, needed when using https://github.com/habi/latex/blob/master/draw_a_scalebar.py 39 | \newlength\imagewidth 40 | \newlength\imagescale 41 | 42 | %Configure listings 43 | \lstset{basicstyle=\footnotesize, 44 | breakatwhitespace=true, 45 | breaklines=true, 46 | keywordstyle=\color{blue}, 47 | stringstyle=\color{orange}, 48 | commentstyle=\color{red}, 49 | numbers=left, 50 | numbersep=5pt, 51 | stepnumber=2, 52 | numberstyle=\tiny\color{gray}, 53 | rulecolor=\color{black}, 54 | showspaces=false, 55 | title=\lstname, 56 | backgroundcolor=\color{gray!10}, 57 | frame=lines} 58 | 59 | \title{Awesome document} 60 | \subtitle{Version \gitAbbrevHash} 61 | \author{David Haberthür% 62 | \thanks{\href{mailto:david.haberthuer@psi.ch}{david.haberthuer@psi.ch}, +41 56 310 31 80}% 63 | \and% 64 | Someone else, maybe% 65 | \thanks{\href{mailto:user@domain.com}{user@domain.com}, +1 23 45 67 890}% 66 | } 67 | \date{\today} 68 | 69 | % recalculate type area if we did something funky with the fonts 70 | \recalctypearea 71 | 72 | \begin{document} 73 | 74 | \maketitle 75 | 76 | \blinddocument 77 | 78 | \printbibliography 79 | 80 | \end{document} 81 | -------------------------------------------------------------------------------- /movie.avi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/habi/latex/bee3ab77416c36bdb1b08fa420f11da8d0c76586/movie.avi -------------------------------------------------------------------------------- /multi-axis-plot.tex: -------------------------------------------------------------------------------- 1 | % Document to show how to plot two datasets (one with logarithmic axes and one without into the same plot. 2 | % Based on information found in http://www.tug.org/TUGboat/tb31-1/tb97wright-pgfplots.pdf and http://tex.stackexchange.com/a/42752/828 3 | % This file here is compilable even without the datafiles, thanks to the 'filecontents' package. 4 | % Real usage based on much bigger datafiles, which make the plot actually look interesting :) 5 | \documentclass{article} 6 | 7 | \usepackage{siunitx} 8 | \usepackage{tikz} 9 | \usepackage[active,tightpage]{preview} 10 | \PreviewEnvironment{tikzpicture} 11 | \usepackage{pgfplots} 12 | \pgfplotsset{compat=1.3} 13 | 14 | %%%%%%%%%% Cenerate some truncated input data for GitHub 15 | \usepackage{filecontents} 16 | 17 | \begin{filecontents}{gadox.dat} 18 | # from http://physics.nist.gov/PhysRefData/FFast/html/form.html 19 | # Data for Gd2O2S, E=0.001-120 keV 20 | # 21 | # [µ/rho] 22 | # E Total 23 | # keV cm2 g-1 24 | 8.566815e-03 1.325275e+05 25 | 8.694678e-03 1.344379e+05 26 | 9.093814e-03 1.404058e+05 27 | 9.233005e-03 1.424885e+05 28 | \end{filecontents} 29 | 30 | \begin{filecontents}{csi.dat} 31 | # from http://physics.nist.gov/PhysRefData/FFast/html/form.html 32 | # Data for CsI, E=0.001-120 keV 33 | # 34 | # [µ/rho] 35 | # E Total 36 | # keV cm2 g-1 37 | 4.984800E-02 4.344176E+03 38 | 5.059200E-02 4.857371E+03 39 | 5.302035E-02 7.804916E+03 40 | 5.667876E-02 1.852014E+04 41 | \end{filecontents} 42 | 43 | \begin{filecontents}{053.dat} 44 | # https://w9.siemens.com/cms/oemproducts/Home/X-rayToolbox/spektrum/Pages/radIn.aspx 45 | # Anode material: Tungsten 46 | # Peak tube voltage: 47 | # (range 30 - 140 kV) kV 53 kV 48 | # Relative voltage ripple: 0.04 49 | # Air kerma 0.0000025 Gy 50 | # Mean energy 36.350311 keV 51 | # List of filters 52 | # Material Thickness, mm 53 | # Al 4 54 | 8 0 55 | 9 5.38658e-018 56 | 10 2.47217e-012 57 | 11 3.21707e-009 58 | 12 1.31631e-006 59 | \end{filecontents} 60 | 61 | \begin{filecontents}{080.dat} 62 | # https://w9.siemens.com/cms/oemproducts/Home/X-rayToolbox/spektrum/Pages/radIn.aspx 63 | # Anode material: Tungsten 64 | # Peak tube voltage: 65 | # (range 30 - 140 kV) kV 80 kV 66 | # Relative voltage ripple: 0.04 67 | # Air kerma 0.0000025 Gy 68 | # Mean energy 46.961220 keV 69 | # List of filters 70 | # Material Thickness, mm 71 | # Al 4 72 | 8 0 73 | 9 3.65939e-018 74 | 10 9.22966e-013 75 | 11 1.11716e-009 76 | 12 4.71905e-007 77 | \end{filecontents} 78 | 79 | \begin{filecontents}{120.dat} 80 | # https://w9.siemens.com/cms/oemproducts/Home/X-rayToolbox/spektrum/Pages/radIn.aspx 81 | # Anode material: Tungsten 82 | # Peak tube voltage: 83 | # (range 30 - 140 kV) kV 120 kV 84 | # Relative voltage ripple: 0.04 85 | # Air kerma 0.0000025 Gy 86 | # Mean energy 58.178048 keV 87 | # List of filters 88 | # Material Thickness, mm 89 | # Al 4 90 | 8 0 91 | 9 2.69258e-018 92 | 10 6.87362e-013 93 | 11 1.00927e-009 94 | 12 2.99634e-007 95 | \end{filecontents} 96 | 97 | \pgfplotstableread{gadox.dat}\gadox 98 | \pgfplotstableread{csi.dat}\csi 99 | \pgfplotstableread{053.dat}\x 100 | \pgfplotstableread{080.dat}\y 101 | \pgfplotstableread{120.dat}\z 102 | %%%%%%%%%% Cenerate some truncated input data for GitHub 103 | 104 | %% real input data 105 | %\pgfplotstableread{/afs/psi.ch/user/h/haberthuer/EssentialMed/Documents/SLS-Symposium-Instrumentation/Gd2O2S.dat}\gadox 106 | %\pgfplotstableread{/afs/psi.ch/user/h/haberthuer/EssentialMed/Documents/SLS-Symposium-Instrumentation/CsI.dat}\csi 107 | %\pgfplotstableread{/afs/psi.ch/user/h/haberthuer/EssentialMed/Dev/Spectra/Xray-Spectrum_053kV.txt}\x 108 | %\pgfplotstableread{/afs/psi.ch/user/h/haberthuer/EssentialMed/Dev/Spectra/Xray-Spectrum_080kV.txt}\y 109 | %\pgfplotstableread{/afs/psi.ch/user/h/haberthuer/EssentialMed/Dev/Spectra/Xray-Spectrum_120kV.txt}\z 110 | 111 | \begin{document} 112 | 113 | \begin{tikzpicture} 114 | \pgfplotsset{scale only axis,xmin=0,xmax=120,ymin=0} 115 | 116 | \begin{semilogyaxis}[ 117 | axis y line*=left, 118 | xlabel={Energy \si{\kilo\volt}}, 119 | ylabel={Absorption Coefficient [\si{\centi\meter\squared\per\gram}]}, 120 | ] 121 | \addplot +[mark=none] table {\gadox};\label{gadox} 122 | \addplot +[mark=none] table {\csi};\label{csi} 123 | \end{semilogyaxis} 124 | 125 | \begin{axis}[ 126 | axis y line*=right, 127 | axis x line = none, 128 | ylabel=Photons, 129 | ] 130 | \addlegendimage{/pgfplots/refstyle=gadox} 131 | \addlegendentry{GadOx} 132 | \addlegendimage{/pgfplots/refstyle=csi} 133 | \addlegendentry{CsI} 134 | \addplot +[mark=none,green] table {\x}; 135 | \addlegendentry{\SI{53}{\kilo\volt}} 136 | \addplot +[mark=none,cyan] table {\y}; 137 | \addlegendentry{\SI{80}{\kilo\volt}} 138 | \addplot +[mark=none] table {\z}; 139 | \addlegendentry{\SI{120}{\kilo\volt}} 140 | \end{axis} 141 | 142 | \end{tikzpicture} 143 | \end{document} -------------------------------------------------------------------------------- /multiple_affiliations.tex: -------------------------------------------------------------------------------- 1 | % Multiple affiliations per author. Based on 2 | % http://anthony.liekens.net/index.php/LaTeX/MultipleFootnoteReferences 3 | 4 | \documentclass{scrartcl} 5 | \usepackage{hyperref} 6 | \newcommand{\footremember}[2]{% 7 | \footnote{#2} 8 | \newcounter{#1} 9 | \setcounter{#1}{\value{footnote}}% 10 | } 11 | \newcommand{\footrecall}[1]{% 12 | \footnotemark[\value{#1}]% 13 | } 14 | 15 | \title{How to bowl properly} 16 | \author{% 17 | The Dude\footremember{alley}{Holly Star Lanes Bowling Alley}% 18 | \and Walter Sobchak\footremember{trailer}{Probably somewhere in a trailer park}% 19 | \and Jesus Quintana\footrecall{alley} \footnote{Mexico?}% 20 | \and Uli Kunkel\footrecall{trailer} \footnote{Germany?}% 21 | } 22 | 23 | \begin{document} 24 | \maketitle 25 | This example is based on \href{http://anthony.liekens.net/index.php/LaTeX/MultipleFootnoteReferences}{\emph{How do I refer to the same footnote more than once in LaTeX?}} by \href{http://anthony.liekens.net/}{Anthony Liekens}. 26 | \end{document} 27 | -------------------------------------------------------------------------------- /node-positioning.tex: -------------------------------------------------------------------------------- 1 | % My answer for http://tex.stackexchange.com/q/266206/828 2 | % Direct link: http://tex.stackexchange.com/a/266218/828 3 | \documentclass{standalone} 4 | 5 | \usepackage{tikz} 6 | 7 | \begin{document} 8 | 9 | \begin{tikzpicture} 10 | % left 11 | \node (f) at (0,0) {F}; 12 | \node (d) at (1,1) {D}; 13 | \node (k) at (2,0) {K}; 14 | \node (m) at (1,-1) {M}; 15 | % middle 16 | \node (e) at (3,1) {E}; 17 | \node (c) at (4,1) {C}; 18 | \node (b) at (3,-1) {B}; 19 | \node (h) at (4,-1) {H}; 20 | % right 21 | \node (j) at (5,0) {J}; 22 | \node (a) at (6,1) {A}; 23 | \node (g) at (7,0) {G}; 24 | \node (p) at (6,-1) {P}; 25 | % outer 26 | \node (l) at (0,3) {L}; 27 | \node (n) at (7,3) {N}; 28 | \node (o) at (0,-3) {O}; 29 | \node (i) at (7,-3) {I}; 30 | % connections 31 | \draw (f) -- (d) -- (k) --(m) -- (f); 32 | \draw (k) -- (e) -- (c) -- (j); 33 | \draw (k) -- (b) -- (h) -- (j); 34 | \draw (j) -- (a) -- (g) --(p) -- (j); 35 | \draw (f) -- (l) -- (n) -- (g) -- (i) -- (o) -- (f); 36 | \draw (l) -- (c); 37 | \draw (e) -- (n); 38 | \draw (o) -- (h); 39 | \draw (b) -- (i); 40 | \end{tikzpicture} 41 | 42 | \end{document} -------------------------------------------------------------------------------- /plotting_multiple_files_and_legends.tex: -------------------------------------------------------------------------------- 1 | % Code for http://tex.stackexchange.com/q/136427/828 2 | % Updated with answer, see old revisions for original 3 | \documentclass{article} 4 | \usepackage{siunitx} 5 | \usepackage{pgfplots} 6 | \usepackage[active,tightpage]{preview} 7 | \PreviewEnvironment{tikzpicture} 8 | \usepackage{filecontents} 9 | 10 | \begin{document} 11 | 12 | \begin{filecontents*}{Xray-Spectrum_040kv.txt} 13 | 9 2.23512e-015 14 | 10 2.18948e-009 15 | \end{filecontents*} 16 | 17 | \begin{filecontents*}{Xray-Spectrum_046kv.txt} 18 | 9 1.98718e-015 19 | 10 1.56485e-009 20 | \end{filecontents*} 21 | 22 | \begin{tikzpicture} 23 | \begin{axis} 24 | \foreach \v in {40,46} { 25 | \edef\temp{\noexpand\addlegendentry{\SI{\v}{\kilo\volt}}} 26 | \addplot table {Xray-Spectrum_0\v kv.txt}; 27 | \temp 28 | } 29 | \end{axis} 30 | \end{tikzpicture} 31 | \end{document} -------------------------------------------------------------------------------- /randomwalk.tex: -------------------------------------------------------------------------------- 1 | % random walking according to own experimentations and based on TikZ manual, as 2 | % shown here: http://tex.stackexchange.com/a/11682/828 3 | \documentclass{article} 4 | \usepackage{tikz} 5 | \usepackage[outline]{contour} 6 | \usepackage[active,tightpage]{preview} 7 | \PreviewEnvironment{tikzpicture} 8 | 9 | \begin{document} 10 | 11 | \pgfmathsetseed{1796} 12 | 13 | \begin{tikzpicture} [thick, line cap=round] 14 | \foreach \i in {1,...,10} { 15 | \draw [nearly transparent] (0,0) circle (\i); 16 | }; 17 | % simplest way 18 | \draw [red, rounded corners] (0,0) 19 | \foreach \i in {1,...,100} { -- ++(rand,rand)}; 20 | % angle way, with defined step length 21 | \draw [rounded corners, green] (0,0) 22 | \foreach \i in {1,...,100} { -- ++(rand*360:1)}; 23 | % color the path 24 | % along the way we have to save where we've been at 25 | % we cannot easily use 'rounded corners', look at the example linked above 26 | % (on line 2) if you'd like to do that, since it's more complicated\ldots 27 | \coordinate (current point) at (0,0); 28 | \foreach \i in {0,...,100} { 29 | \draw [blue!\i] (current point) -- ++(rand,rand) node (new point) {}; 30 | \coordinate (current point) at (new point); 31 | } 32 | \fill (0,0) circle (0.125) node [below] {\contour{white}{Start}}; 33 | \end{tikzpicture} 34 | 35 | \end{document} 36 | -------------------------------------------------------------------------------- /redefine-subfloat-caption.tex: -------------------------------------------------------------------------------- 1 | % How to redefine the subcaption to have the subfloats named "Figure" 2 | % For http://tex.stackexchange.com/a/156358/828 3 | 4 | \documentclass{article} 5 | 6 | \usepackage[demo]{graphicx} 7 | \usepackage{blindtext} 8 | \usepackage{subfig} 9 | 10 | \renewcommand{\thesubfigure}{Figure \arabic{subfigure}} 11 | \captionsetup[subfigure]{labelformat=simple, labelsep=colon} 12 | %\captionsetup[subfigure]{labelformat=parens, labelsep=colon} 13 | 14 | \begin{document} 15 | 16 | \blindtext 17 | 18 | \begin{figure}[ht] 19 | \centering 20 | \subfloat[caption]{ 21 | \includegraphics[width=0.4\linewidth]{Screenshots/step1.png} 22 | } 23 | \subfloat[caption]{ 24 | \includegraphics[width=0.41\linewidth]{boundingbox.eps} 25 | } 26 | \end{figure} 27 | 28 | \blindtext 29 | 30 | \end{document} -------------------------------------------------------------------------------- /rose.tex: -------------------------------------------------------------------------------- 1 | % Draw a rose with TikZ 2 | 3 | \documentclass{article} 4 | \usepackage[pdftex,active,tightpage]{preview} 5 | \usepackage{tikz} 6 | \usetikzlibrary{patterns} 7 | \PreviewEnvironment{tikzpicture} 8 | \begin{document} 9 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 10 | \def\radius{1} 11 | \def\ticklength{.3} 12 | \def\labelshift{0.35} 13 | \def\overlap{.075} 14 | \def\projangle{17} 15 | \def\angleshift{2} 16 | \begin{tikzpicture}[scale=1.6] 17 | \scriptsize 18 | %% Fill CenterScan 19 | \pattern [pattern=checkerboard light gray] (1,0) -- (3,0) arc (0:180:3*\radius) -- (-1,0) arc (180:0:\radius); 20 | \fill [color=red,nearly transparent] (1,0) -- (3,0) arc (0:180:3*\radius) -- (-1+\overlap,0) arc (180:0:\radius-\overlap); 21 | %% Fill RingScan 1 22 | \fill [color=green,nearly transparent] (0,0) circle (\radius+\overlap); 23 | %% Fill RingScan 2 24 | \pattern [pattern=horizontal lines gray] (1,0) -- (3,0) arc (0:-180:3*\radius) -- (-1,0) arc (-180:0:\radius); 25 | \fill [color=blue,nearly transparent] (1,0) -- (3,0) arc (0:-180:3*\radius) -- (-1+\overlap,0) arc (-180:0:\radius-\overlap); 26 | %% Projections 27 | \draw [ultra thick,color=red](\projangle:\radius-\overlap) -- (\projangle:3*\radius); 28 | \draw [ultra thick,color=green](\projangle+180+\angleshift:\radius+\overlap) -- (\projangle+\angleshift:\radius+\overlap); 29 | \draw [ultra thick,color=blue](\projangle+180:3*\radius) -- (\projangle+180:\radius-\overlap); 30 | %% inner ring 31 | % ring 32 | \draw (0,0) circle (\radius); 33 | % projections 34 | \foreach \angle in {0,20,...,181} 35 | \draw (\angle:-\radius) -- (\angle:\radius+\ticklength); 36 | \foreach \angle in {0,5,...,179} 37 | { 38 | % inner ticks 39 | \draw (\angle:-.5*\ticklength) -- (\angle:.5*\ticklength); 40 | % % median ticks 41 | % \draw [dotted] (\angle:.5*\ticklength) -- (\angle:\radius-.5*\ticklength); 42 | % \draw [dotted] (180+\angle:.5*\ticklength) -- (180+\angle:\radius); 43 | % outer ticks 44 | \draw (\angle:\radius-.5*\ticklength) -- (\angle:\radius); 45 | } 46 | % labels 47 | \foreach \angle / \label in {0/1,30/200,60/500,90/750,120/1000,150/1250,180/1500} 48 | \draw (\angle:\radius-\labelshift) node {\label}; % {\textsf{\label}}; 49 | %% outer ring 50 | % circle 51 | \draw (0,0) circle (3*\radius); 52 | % projections 53 | \foreach \angle in {0,20,...,719} 54 | \draw (.5*\angle:\radius) -- (.5*\angle:3*\radius+\ticklength); 55 | \foreach \angle in {0,2.5,...,359} 56 | { 57 | % inner ticks 58 | \draw (\angle:3*\radius-.5*\ticklength) -- (\angle:3*\radius+.5*\ticklength); 59 | % % median ticks 60 | % \draw [dotted] (\angle:\radius+.5*\ticklength) -- (\angle:3*\radius-.5*\ticklength); 61 | % outer ticks 62 | \draw (\angle:\radius) -- (\angle:\radius+.5*\ticklength); 63 | } 64 | % labels 65 | \foreach \angle / \label in {2/1 and,15/200,30/500,45/750,60/1000,75/1250,90/1500,105/1750,120/2000,135/2250,150/2500,165/2750,178/3000} 66 | \draw (\angle:3*\radius+\labelshift) node {\label}; 67 | \foreach \angle / \label in {2/and 1,15/200,30/500,45/750,60/1000,75/1250,90/1500,105/1750,120/2000,135/2250,150/2500,165/2750,178/3000} 68 | \draw (180+\angle:3*\radius+\labelshift) node {\label}; 69 | \end{tikzpicture}% 70 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 71 | \end{document} 72 | 73 | 74 | -------------------------------------------------------------------------------- /scale_bars.tex: -------------------------------------------------------------------------------- 1 | % This document show you how to draw a scalebar onto a figure. If you want to 2 | % draw a scale-bar and you don't really know the length, take a look at 3 | % 'scalebar.tex' in this repository, which also shows you how to calculate the 4 | % length, depending on the image. 5 | 6 | \documentclass{article} 7 | \usepackage{graphicx} 8 | \usepackage{tikz} 9 | \usetikzlibrary{shapes.arrows} 10 | \usepackage{siunitx} 11 | \usepackage[graphics,tightpage,active]{preview} 12 | \PreviewEnvironment{tikzpicture} 13 | 14 | \newcommand{\imsize}{\linewidth} 15 | \newlength\imagewidth 16 | \newlength\imagescale 17 | 18 | \begin{document} 19 | \pgfmathsetlength{\imagewidth}{\linewidth} % desired displayed width of image 20 | \pgfmathsetlength{\imagescale}{\imagewidth/670} % pixel width of imagefile used below 21 | 22 | % adjust scale of tikzpicture (and direction of y) such that pixel 23 | % coordinates can be used for drawing overlays: 24 | \begin{tikzpicture}[x=\imagescale,y=-\imagescale] 25 | % place image (integer coordinates refer to pixel centers): 26 | \node[anchor=north west,inner sep=0pt,outer sep=0pt] at (0,0) {\includegraphics[width=\imagewidth]{scalebarimage}}; 27 | \draw[|-|,red,ultra thick] (25,500) -- (175,500) node [midway,above] {\SI{300}{\micro\meter}}; % coordinates where the scalebar should be drawn, scaled with the size of the image. 28 | \end{tikzpicture} 29 | \end{document} 30 | -------------------------------------------------------------------------------- /scalebar.m: -------------------------------------------------------------------------------- 1 | clc;clear all;close all; 2 | 3 | [ filename, pathname] = ... 4 | uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';... 5 | '*.*','All Files' },'Choose Input Image'); 6 | 7 | image=imread([pathname filesep filename]); 8 | 9 | InputDialog={'Length of the Scale Bar to draw [cm]'}; 10 | Name='Input the Details'; 11 | NumLines=1; 12 | Defaults={'21'}; 13 | UserInput=inputdlg(InputDialog,Name,NumLines,Defaults); 14 | scale = str2num(UserInput{1}); 15 | scale = scale * 10; % to convert from cm to mm 16 | figure 17 | imshow(image) 18 | hold on 19 | 20 | h = helpdlg('choose start-point of scalebar','ScaleBar'); 21 | uiwait(h); 22 | [ x1,y1 ] = ginput(1); 23 | h = helpdlg('choose end-point of scalebar','ScaleBar'); 24 | uiwait(h); 25 | [ x2,y2 ] = ginput(1); 26 | 27 | line([x1,x2],[y1,y2]); 28 | 29 | length = sqrt((x1-x2)^2+(y1-y2)^2); 30 | dpixel = scale / length * 100; 31 | um = 100 / dpixel * 50; 32 | 33 | title([ 'Vectorlength: ' num2str(round(length)) 'px = ' num2str(scale) ... 34 | 'mm, 100px = ' num2str(round(dpixel)) 'mm, ' num2str(round(um)) ... 35 | 'px = 5 cm']) 36 | 37 | h = helpdlg(['Image Width = ' num2str(size(image,2)) ' px - (x1,y1) = (' ... 38 | num2str(round(x1)) ',' num2str(round(y1)) ') - (x2, y2) = (' ... 39 | num2str(round(x2)) ',' num2str(round(y2)) ')'],'Positions'); 40 | 41 | disp('copy the stuff below to your .tex-file') 42 | disp('%-------------') 43 | disp('\newcommand{\imsize}{\linewidth} % makes life easier with images') 44 | disp('\newlength\imagewidth % needed for scalebars') 45 | disp('\newlength\imagescale % needed for scalebars') 46 | disp('\pgfmathsetlength{\imagewidth}{\imsize} % desired displayed width of image') 47 | disp(['\pgfmathsetlength{\imagescale}{\imagewidth/' num2str(size(image,2)) '} % pixel width of imagefile used below']) 48 | disp('%-------------') 49 | disp('\begin{tikzpicture}[x=\imagescale,y=-\imagescale]') 50 | disp(' \def\x{100}') 51 | disp(' \def\y{100}') 52 | disp(' \node[anchor=north west,inner sep=0pt,outer sep=0pt] at (0,0)') 53 | disp([' {\includegraphics[width=\imagewidth]{' filename '}};' ]) 54 | disp([' % ' num2str(round(length)) 'px = ' num2str(scale) 'mm > 100px = ' num2str(round(dpixel)) 'mm > ' num2str(round(um)) 'px = 50mm']) 55 | disp([' \draw[|-|,thick] (' num2str(round(x1)) ',' num2str(round(y1)) ... 56 | ') -- (' num2str(round(x2)) ',' num2str(round(y2)) ') node [sloped,midway,above] '... 57 | '{\SI{' num2str(scale) '}{\milli\meter}};' ]) 58 | disp([' \draw[|-|,thick] (\x,\y) -- (\x+' num2str(round(um)) ',\y) node [midway,above] {\SI{5}{\centi\meter}};']) 59 | disp('\end{tikzpicture}%'); 60 | disp('%-------------') 61 | disp('copy the stuff above to your .tex-file') -------------------------------------------------------------------------------- /scalebar.tex: -------------------------------------------------------------------------------- 1 | % This document can be used to put scalebars on figures. without doing any 2 | % calculations. Needs 'scalebar.m' (and MATLAB) and 'scalebarimage.jpg', which 3 | % are also my the latex-repository on Github 4 | 5 | %- Start MATLAB, load scalebar.m and start it. 6 | %- The script prompts you to load an image, choose “scalebarimage.jpg” you've 7 | % downloaded from above. 8 | %- The script prompts you to define the length of the scale bar you are going 9 | % to draw in the next step, choose the default “21 cm” for now 10 | %- The script displays the image of my head and asks you to define a starting 11 | % point of the scale-bar, choose the tip of the nose 12 | %- After that, choose the back of my head for the end of the scale-bar 13 | %- Note the “Positions” shown in the help-dialog, these are to make sure you 14 | % clicked correctly and that the positions are correct. 15 | %- copy the output in the command-line-section of MATLAB 16 | %- paste this output into your .tex-file 17 | %- if the .tex file and the image are in the same folder, just proceed, if not, 18 | % change the path to the image! 19 | %- compile the file 20 | % 21 | % Figure 1 of the document should show the exact same scale-bar you've drawn in 22 | % MATLAB overlayed over the image and a second scale bar which shows a 23 | % reasonable length (5cm in our case). 24 | % You can change \def\x{100} and \def\y{100} on lines 24 and 25 of the copied 25 | % text to position the scale bar where you'd like to have it and uncomment line 26 | % 29 to turn off the original scale bar. 27 | % 28 | % Please enjoy typographically correct scale bars in the resulting pdf (47 kB) 29 | 30 | \documentclass{article} 31 | 32 | \usepackage{tikz} % makes the scalebar 33 | \usepackage[utf8]{inputenc} % so i can write my name without contortions 34 | \usepackage{siunitx} % typographically correct units 35 | \usepackage{hyperref} % links in pdf 36 | 37 | \newlength\imagewidth % needed for scalebars 38 | \newlength\imagescale % ditto 39 | 40 | \begin{document} 41 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 42 | \author{David Haberthür} 43 | \title{David Haberthür's Head - Scalebar} 44 | \date{\today} 45 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 46 | \maketitle 47 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48 | \begin{figure}[h] 49 | \centering 50 | %%% 51 | COPY MATLAB-STUFF HERE 52 | %%% 53 | \caption{Three dimensional visualization of David Haberthürs Head, released under a \href{http://creativecommons.org/licenses/by/2.0/deed.en_GB}{creative commons Attribution 2.0 Generic license} by the owner of the head.} 54 | \label{fig:head} 55 | \end{figure} 56 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 57 | \end{document} 58 | -------------------------------------------------------------------------------- /scalebarimage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/habi/latex/bee3ab77416c36bdb1b08fa420f11da8d0c76586/scalebarimage.jpg -------------------------------------------------------------------------------- /serial-letter.tex: -------------------------------------------------------------------------------- 1 | % For http://tex.stackexchange.com/a/215958/828, entirely based on 2 | % http://de.wikibooks.org/wiki/LaTeX-W%C3%B6rterbuch:_Serienbrief 3 | 4 | \documentclass[11pt]{letter} 5 | 6 | \address{Jane Doe\\Title\\Company\\Phone \#} 7 | \signature{Jane Doe} 8 | 9 | \begin{document} 10 | 11 | \newcommand\writeletter[4]{ 12 | \begin{letter}{#1 #2\\#3\\#4} 13 | \opening{Dear #1!} 14 | Here's a very long text to #1 at #2 in #3. 15 | \closing{With best regards to #3} 16 | \end{letter} 17 | } 18 | 19 | \writeletter{Company 1}{5555 N 5th St}{Townsville, CA}{55555} 20 | \writeletter{Company 2}{5556 N 5th St}{Townsville, CA}{55556} 21 | \writeletter{Company 3}{5557 N 5th St}{Townsville, CA}{55557} 22 | 23 | \end{document} 24 | -------------------------------------------------------------------------------- /sizing.tex: -------------------------------------------------------------------------------- 1 | % Since I always forget the correct order of the commands for sizing text in 2 | % \LaTeX I made this document to put onto my whiteboard. 3 | 4 | \documentclass{scrartcl} 5 | \usepackage[pdftex,active,tightpage]{preview} 6 | \begin{document} 7 | \begin{preview} 8 | \centering 9 | \tiny \verb+\tiny+\\ 10 | \scriptsize \verb+\scriptsize+\\ 11 | \footnotesize \verb+\footnotesize+\\ 12 | \small \verb+\small+\\ 13 | \normalsize \verb+\normalsize+\\ 14 | \large \verb+\large+\\ 15 | \Large \verb+\Large+\\ 16 | \LARGE \verb+\LARGE+\\ 17 | \huge \verb+\huge+\\ 18 | \Huge \verb+\Huge+\\ 19 | \end{preview} 20 | \end{document} 21 | -------------------------------------------------------------------------------- /subcaption.tex: -------------------------------------------------------------------------------- 1 | % Answer for http://tex.stackexchange.com/a/136228/828, in which I learned about the deprecation of the subfigure and subfig packages, according to https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats 2 | \documentclass{article} 3 | 4 | \usepackage[demo]{graphicx} 5 | \usepackage{subcaption} 6 | 7 | \begin{document} 8 | 9 | \begin{figure} 10 | \centering 11 | \subcaptionbox{subcaption}{% 12 | \includegraphics[width=6cm,height=3cm]{gaussian}% 13 | }% 14 | \subcaptionbox{subcaption}{% 15 | \includegraphics[width=6cm,height=3cm]{star}% 16 | }% 17 | \\% 18 | \subcaptionbox{subcaption}{% 19 | \includegraphics[width=6cm,height=3cm]{heart}% 20 | }% 21 | \caption{figure caption} 22 | \label{fig:label} 23 | \end{figure} 24 | 25 | \end{document} -------------------------------------------------------------------------------- /table_alignment.tex: -------------------------------------------------------------------------------- 1 | % Code for http://tex.stackexchange.com/a/196987/828 2 | % Solving tabular alignment problems 3 | \documentclass{standalone} 4 | \usepackage{booktabs} 5 | 6 | \begin{document} 7 | 8 | \begin{tabular}{r c c c c c} 9 | \toprule 10 | ‎j/i & 1:Tumor & 2:Envir & 3:Leuk & 4:Lymph & 5:Macroph \\ 11 | \midrule 12 | Tumor & 0 & 1 ‎& \(‎\pm1\) & \(\pm1\) & \(\pm1\)\\ 13 | Envir & 1 & 0 & 0 & 0 & 0\\ 14 | Leuk & \(‎\pm1\) & ‎0 ‎& 0‎ & 0 & 0 \\ 15 | Lymph & \(‎\pm1\) & ‎0 ‎& 0‎ & 0 & \(‎\pm1\) \\ 16 | Macroph & \(‎\pm1\) & ‎0 ‎& 0‎ & 0 & 0 \\ 17 | \bottomrule 18 | \end{tabular} 19 | 20 | \end{document} -------------------------------------------------------------------------------- /tikz-timing.tex: -------------------------------------------------------------------------------- 1 | % Answer for http://tex.stackexchange.com/a/290027/828 2 | % *Entirely* based on http://www.texample.net/tikz/examples/more-tikz-timing-examples/ where (most probably) the original poster copied the code wrongly. 3 | \documentclass[convert]{standalone} 4 | 5 | \usepackage{tikz-timing} 6 | \usetikztiminglibrary[new={char=Q,reset char=R}]{counters} 7 | 8 | \begin{document} 9 | 10 | \begin{tikztimingtable} 11 | CPOL =0 & LL 15{ T} LL \\ 12 | CPOL =1 & HH 15{ T} HH \\ 13 | & H 17L H \\ 14 | \\ 15 | Cycle \# & U R 8{2 Q} 2U \\ 16 | MISO & D{z} R 8{2 Q} 2D{z} \\ 17 | MOSI & D{z} R 8{2 Q} 2D{z} \\ 18 | \\ 19 | Cycle \# & UU R 8{2 Q} U \\ 20 | MISO & D{z}U R 8{2 Q} D{z} \\ 21 | MOSI & D{z}U R 8{2 Q} D{z} \\ 22 | \extracode 23 | % Add vertical lines in two colors 24 | \begin{pgfonlayer}{background} 25 | \begin{scope}[semitransparent,semithick] 26 | \vertlines[red]{2.1,4.1,...,17.1} 27 | \vertlines[blue]{3.1,5.1,...,17.1} 28 | \end{scope} 29 | \end{pgfonlayer} 30 | % Add big group labels 31 | \begin{scope}[font =\sffamily \Large ,shift={(-6em,-0.5)},anchor=east] 32 | \node at (0,0){SCK}; 33 | \node at (0,-3){SS}; 34 | \node at (1ex,-9){CPHA=0}; 35 | \node at (1ex,-17){CPHA =1}; 36 | \end{scope} 37 | \end{tikztimingtable} 38 | 39 | \end{document} -------------------------------------------------------------------------------- /vertical_space_before_table.tex: -------------------------------------------------------------------------------- 1 | % My answer (http://tex.stackexchange.com/a/204164/828) for http://tex.stackexchange.com/q/204159/828 2 | \documentclass[parskip]{scrartcl} 3 | %\documentclass{article} 4 | %\setlength\parindent{0pt} 5 | %\setlength\parskip{10pt} 6 | 7 | \usepackage{siunitx} 8 | \usepackage{booktabs} 9 | \usepackage{blindtext} 10 | \usepackage{hyperref} 11 | 12 | \begin{document} 13 | 14 | \blindtext 15 | 16 | Volume of the hall \(V = \SI{1500}{\cubic\metre}\), details can be found in \autoref{tab:hall details}. 17 | 18 | %\vspace{2cm} 19 | 20 | \begin{table}[h!] 21 | \centering 22 | \caption{Details of the hall} 23 | \label{tab:hall details} 24 | \begin{tabular}{ccS} 25 | \toprule 26 | Surface & Area (\si{\metre\squared}) & {Coefficient of absorption}\\ 27 | \midrule 28 | ceiling & 140 & 0.8 \\ 29 | walls & 260 & 0.03 \\ 30 | floor & 140 & 0.06 \\ 31 | \bottomrule 32 | \end{tabular} 33 | \end{table} 34 | 35 | \blindtext 36 | 37 | \end{document} -------------------------------------------------------------------------------- /waferdiameter.tex: -------------------------------------------------------------------------------- 1 | % I used that drawing for an email to a client. Shows a small example of using 2 | % the 'calc' library of TikZ 3 | 4 | \documentclass{scrartcl} 5 | \usepackage{tikz} 6 | \usetikzlibrary{calc} 7 | \usepackage{siunitx} 8 | \DeclareSIUnit\inch{in} 9 | \usepackage[active,tightpage]{preview} 10 | \PreviewEnvironment{tikzpicture} 11 | \begin{document} 12 | \begin{tikzpicture}[ultra thick] 13 | \draw [fill=lightgray] (0,0) circle (8); 14 | \newcommand\Square[1]{+(-#1,-#1) rectangle +(#1,#1)} % hat tip to http://tex.stackexchange.com/a/58930/828 15 | \draw [fill=white!60!black,draw=black] (0,0) \Square{{4*sqrt(2)}}; 16 | \def\angle{60} 17 | \draw [<->,rotate=\angle] (0,0) -- (0,8) node [midway,above,sloped,rotate=\angle+180] {\(r_{w}=\SI{4}{\inch}=\SI{10.16}{\centi\meter}\)}; 18 | \def\sidelength{5.66} 19 | \def\height{-4*0.68} 20 | \draw [<->] (-\sidelength,\height) -- (\sidelength,\height) node [midway, above] {\(l_{sq}=r_{w}\sqrt{2}=\SI{\sidelength}{\inch}=\SI{14.37}{\centi\meter}\)}; 21 | \end{tikzpicture} 22 | \end{document} 23 | -------------------------------------------------------------------------------- /watermark.tex: -------------------------------------------------------------------------------- 1 | % Watermark a document as confidential (or something else) 2 | 3 | \documentclass{scrartcl} 4 | \usepackage[]{draftwatermark} % try firstpage as option 5 | \usepackage{lipsum} 6 | 7 | \title{Lorem ipsum} 8 | \author{David Haberth\"ur} 9 | % Use the following to make modification 10 | %\SetWatermarkAngle{12} 11 | %\SetWatermarkLightness{0.618} 12 | %\SetWatermarkScale{2.2} 13 | \SetWatermarkText{confidentidal, do not redistribute!} 14 | 15 | \begin{document} 16 | \maketitle 17 | \lipsum 18 | \end{document} 19 | -------------------------------------------------------------------------------- /wide-table-with-long-cells.tex: -------------------------------------------------------------------------------- 1 | % Answer for http://tex.stackexchange.com/a/262173/828 2 | 3 | \documentclass{article} 4 | \usepackage{lipsum} 5 | \usepackage{tabularx} 6 | \usepackage{booktabs} 7 | 8 | \begin{document} 9 | 10 | \lipsum[1] 11 | 12 | \begin{table}[h] 13 | \centering 14 | \caption{Selected Ebola Epidemic Compartmental Models, Analyses and Problem Formulations with References} 15 | \small 16 | \noindent\makebox[\textwidth]{% 17 | \begin{tabularx}{1.4\linewidth}{XlXXXl} 18 | \toprule 19 | Compartmental\newline Model & Analysis & Problem\newline Formulation & Objective & Control\newline Intervention & Reference \\ 20 | \midrule 21 | SEIT & Sensitivity & Differential & Evaluate various intervention strategies & Vaccination & [1] \\ 22 | & & & Determine model parameters by least square method &\\ 23 | \end{tabularx} 24 | } 25 | \end{table} 26 | 27 | \lipsum[1] 28 | 29 | \end{document} --------------------------------------------------------------------------------