*.aux *.glo *.idx *.log *.toc *.ist *.acn *.acr *.alg *.bbl *.blg *.dvi *.glg *.gls *.ilg *.ind *.lof *.lot *.maf *.mtc *.mtc1 *.out auto
Posts mit dem Label latex werden angezeigt. Alle Posts anzeigen
Posts mit dem Label latex werden angezeigt. Alle Posts anzeigen
Freitag, 28. August 2015
.gitignore file for latex
Donnerstag, 16. Juli 2015
cut out part of figure in tikz
To cut out a figure (here i used a rule instead) you can use a node shape as a cut out mask as shown in the following:
instead of \rule{width}{height} you can use a \includegraphics command.
For a rectangle be aware that you have to set the minimum width and minimum height the same size as the picture otherwise a white border will remain.
\begin{tikzpicture}
\node[regular polygon, path picture={
\node at (path picture bounding box.center)
{ \rule{4cm}{3cm} };
}
,minimum width=2.5cm,minimum height=2cm] {};
\end{tikzpicture}
instead of \rule{width}{height} you can use a \includegraphics command.
For a rectangle be aware that you have to set the minimum width and minimum height the same size as the picture otherwise a white border will remain.
Mittwoch, 15. Juli 2015
3d plots in tikz
To plot a 3d plot with latex in tikz you should use the tikz3dplot package:
you can define the coordinate system by using:
after that you can use 3d coordinate definitions:
\usepackage{tikz-3dplot}
you can define the coordinate system by using:
\tdplotsetmaincoords{70}{110}
after that you can use 3d coordinate definitions:
\begin{tikzpicture}[tdplot_main_coords]
\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
\end{tikzpicture}
shift in nodes in tikz
for a shift in one direction use the option:
yshift=LENGTH xshift=LENGTH
for a shift in both directions use:
shift=({XSHIFT,YSHIFT})
Example:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (4,4);
\node (A) at (2,1) {A};
\path ([yshift=2cm]A) node {B};
\node (C) at ([yshift=1cm]A) {C};
\node (D) at ([shift=({1cm,1cm})]A) {D};
\end{tikzpicture}
\end{document}
horizontal and vertical centering in subfigures
subfigures in a figure environment:
\begin{figure}
\end{figure}
adding centered graphics with different heights:
\begin{figure}
\rule{3cm}{5cm}
\begin{minipage}[b][5cm][c]{2.5cm}
\color{red}{\rule{2.5cm}{2cm}}
\vfill
\color{blue}{\rule{2.5cm}{2cm}}
\end{minipage}
\end{figure}
Change separation length in itemize latex
\setlength\itemsep{1em}
abbreviations/acronyms via the acro package in latex
The best package for acronyms in latex documents is
\usepackage{acro}
To define acronyms you use the following commands:
\DeclareAcronym{command}{short=shortform,long=longform}
You can use the acronyms in a text via
\ac{command}
changing \ac into
\Ac -capital initial
\acp -plural
\ac* -without marking it as already present
\acl - long form
\acs - short form
for follow reading:
http://mirror.unl.edu/ctan/macros/latex/contrib/acro/acro_en.pdfformulas in latex
For a single line of equation:
For a multiline equation, which can be aligned:
For a multiline equation:
\begin{equation}
\end{equation}
For a multiline equation, which can be aligned:
\begin{align}
\end{align}
For a multiline equation:
\begin{gather}
\end{gather}
Dienstag, 21. April 2015
Barrier for floats
If you want to create a barrier for floats created via the
\begin{figure}
\end{figure}
or
\begin{table}
\end{table}
environments you can use the floatbarrier function when using the placeins-package
\usepackage{placeins}
\Floatbarrier
Donnerstag, 15. Januar 2015
round numbers in tikz with pgfmath
To round numbers using pgfplots in the tikzpicture environment use \pgfmathparse to calculate the desired value and then print it to with \pgfmathprintnumber or print it to a variable with \pgfmathprintnumberto and use the optional parameter precision, as shown in the following:
\pgfmathparse{10.042/1.54}
\pgfmathprintnumberto[precision=2]{\pgfmathresult}{\value}
\value
Mittwoch, 17. Dezember 2014
layers in tikz in latex
To define a layer in tikz you would first in the preamble define a new layer with a defined name (here i chose "layer") and then set the order of the layers especially in comparison to the standard "main" layer.
in the plotting step you can then explicitly plot on a different layer by using the pgfonlayer environment
\pgfdeclarelayer{layer} % declare layer
\pgfsetlayers{layer,main} % set the order of the layers (main is the standard layer)
in the plotting step you can then explicitly plot on a different layer by using the pgfonlayer environment
\begin{pgfonlayer}{layer}
\draw[ultra thick] (0.0,0.0) -- ++ (1.0,0.0);
\end{pgfonlayer}
Freitag, 14. November 2014
latex trim image
to cut an image in latex you can simply use the trim option and then define then use the clip option as follow:
\includegraphics[trim={left low right top},clip]{./test.png}
Donnerstag, 23. Oktober 2014
Latex (tikz) emphasize part of graphic
http://tex.stackexchange.com/questions/181098/semitransparent-outside-clipped-region
Sonntag, 1. Juni 2014
Latex write to a external file
To write to another text file in the latex document (FILE) you have to open it at the begin of the document and close it at the end of the document, like explained in the following:
One can write to this file by using the following command:
For example one could include the file at the end of the document by using:
\AtBeginDocument{%
\Opensolutionfile{FILE}
}
\AtEndDocument{%
\Closesolutionfile{FILE}
}
One can write to this file by using the following command:
\Writetofile{FILE}{text}
For example one could include the file at the end of the document by using:
\IfFileExists{FILE.tex}{\input{FILE.tex}}{}
Define a new latex class
In order to define a new latex class you have to create a new file including the following statements as a header:
using this header a new class with name CLASSNAME is created (you can also define a comment CLASSCOMMENT) and by using \LoadClass all options of CLASS_TO_LOAD are loaded as predefined. Here as an example a dissertation class, based on the book class is defined:
to load packages (e.g. graphicx) you need to use the following command:
in the follwing you can utilize
And use
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{CLASSNAME}[CLASSCOMMENT]
\LoadClass{CLASS_TO_LOAD}
using this header a new class with name CLASSNAME is created (you can also define a comment CLASSCOMMENT) and by using \LoadClass all options of CLASS_TO_LOAD are loaded as predefined. Here as an example a dissertation class, based on the book class is defined:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{dissertation}[class to write a perfect dissertation]
\LoadClass{book}
to load packages (e.g. graphicx) you need to use the following command:
\RequirePackage{graphixc}
in the follwing you can utilize
\newcommand{}{}
\renewcommand{}{}
to define or change commands.And use
\AtBeginDocument{}
\AtEndDocument{}
to execute commands at the beginning or end of the document.
Change latex command when compiling inside emacs
Emacs adds the following comment commands into a multiple latex file to know which commands to use and to define the master file:
In order to define the latex command e.g. include -shell-escape you have to add the following line before the End: command into the latex file:
%%% Local Variables: %%% mode: latex %%% TeX-master: t %%% End:
In order to define the latex command e.g. include -shell-escape you have to add the following line before the End: command into the latex file:
%%% LaTeX-command: "latex -shell-escape"
Latex define new "section-type"
To define a new section-type you need to use the
titlesec Package:
to define a new section-type you use the titleclass command with name NAME and copy the properties of \PART (e.g. \section)
additionally you need a new counter and a command that gives back the counter:
finally you can define the titleformat and titlespacings:
With options explained here:
\usepackage{titlesec}
to define a new section-type you use the titleclass command with name NAME and copy the properties of \PART (e.g. \section)
\titleclass{\NAME}{option}[\PART]
additionally you need a new counter and a command that gives back the counter:
\newcounter{NAME}
\renewcommand{\theNAME}{\arabic{NAME}}
finally you can define the titleformat and titlespacings:
\titleformat{\NAME}[hang]
{\normalfont } % format of titletext
{{\bf Task \theNAME:} } % command before titletext
{0pt} % spacing after titletext
{} % before code
[] % after code
\titlespacing{\NAME}{0pt}{*4}{*2}
With options explained here:
\titlespacing*{command}{left}{before-sep}{after-sep}
For a more detailed description look into the titlesec documentatio, but these are the most important points.
Montag, 28. April 2014
make gnuplot produce a latex standalone document
gnuplot has a view very good terminals including the epslatex-terminal the only backdraw which i had recently was that the terminal produces either:
- a latex file which can be included in the latex-document
or
- a latex-document which produces a pdf with the minimal-documentclass
but it does not produce a document which can be used via includestandalone.
But now I found a way to do it.
Add at the end of test.tex
- a latex file which can be included in the latex-document
or
- a latex-document which produces a pdf with the minimal-documentclass
but it does not produce a document which can be used via includestandalone.
But now I found a way to do it.
1. create example with epslatex terminal
set terminal epslatex set output "test.tex" plot sin(x) set output
2. Add preamble for standalone figure and add \end{document}
Add at the beginning of test.tex: \documentclass{standalone}
\usepackage{graphicx}
\begin{document}
Add at the end of test.tex
\end{document}
PS: I also wrote a gnuplot script doing all of this:
epslatexterm(name, xsize, ysize, gnuplotcommand) = sprintf('\
name="%s";\
file=name.".tex";\
set terminal epslatex size %s, %s;\
%s;\
set output name.".tex"; \
replot; \
unset output;\
eval bash(''echo \" \\\\begin{document} \" |cat - ''.file.'' > tmp '');\
eval bash(''echo \" \\\\usepackage{graphicx} \" |cat - tmp > tmp2 '');\
eval bash(''echo \" \\\\documentclass{standalone} \" |cat - tmp2 > tmp '');\
eval bash(''echo \" \\\\end{document} \" |cat tmp - > tmp2 '');\
eval bash("sed ''s/".name."/".name."-inc/g'' tmp2 > ".file );\
eval bash(''mv ''.name.''.eps ''.name.''-inc.eps'');\
eval bash(''rm tmp tmp2 -f'');\
set terminal wxt; \
',name,xsize,ysize,gnuplotcommand)
Donnerstag, 16. Januar 2014
latex mix colors with colorlet and xcolor
To mix colors you need to have the xcolor package loaded first via:
And then you can mix two colors with
which means you mix 80% blue with 20% black. If you do not have a second color you mix the first with: "white".
\usepackage{xcolor}And then you can mix two colors with
\colorlet{DarkBlue}{blue!80!black}Dienstag, 14. Januar 2014
latex tables with package booktabs
Latex tables
To use the latex booktabs package simply include:\usepackage{booktabs}
in the header.After this you can make a nice table via:
\begin{table}[h!]
\begin{tabular}{ l l l}
\toprule
First & Second & Third \\
\midrule
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3 \\
1 & 2 & 3 \\
\bottomrule
\end{tabular}
\end{table}
for further tips read the booktabs manual.
Abonnieren
Posts (Atom)


