Archive for the ‘ latex ’ Category

Lslisting untuk program berbeda #Latex

Package lslisting sangat membantu untuk menampilkan kode di Latex. Terkadang kita menulis berbagai macam kode dalam satu latex dan ingin diberi caption berbeda. Supaya tidak menulis lsset berkali-kali, kita bisa menuliskan contoh perintah latex di bawah ini. Contoh dibawah ini berfungsi menulis query dan perintah shellscript.

\lstnewenvironment{query}[1][]{%
\renewcommand{\lstlistingname}{Query}%
\renewcommand{\thelstlisting}{\thechapter.\arabic{lstlisting}}
\lstset{language=SPARQL,#1,frame=single,breaklines=true,basicstyle=\small}}
{}


\lstnewenvironment{sh}[1][]{%
\renewcommand{\lstlistingname}{Kode}%
\renewcommand{\thelstlisting}{\thechapter.\arabic{lstlisting}}%
\lstset{language=sh,#1,frame=single,breaklines=true,basicstyle=\small}}
{}

Baca lebih lanjut

prevent a figure, a table, etc from floation other section #Latex

I just found a great Latex package which called placeins. This package is useful to place your table, figure in the right place. After compiling process, your figures and tables can be placed anywhere in your latex document. You just type \FloatBarrier before your figures or tables. Then, you will see your stuffs are inside the desired section.

Happy Latexing Anyone 😀

#Latex Nested folder with Subfiles package

I got a handy and pretty solution to deal with a nested files issue while I am using subfiles package. I am a fan of subfiles because we can compile and see a latex file without involving the main latex file.

suppose that, we have a latex project:
main.tex
-chapter1
–chapter1.tex
-figures
–chapter1
—figure.jpg

then we should write the main.tex and chapter1.tex as follows:

main.tex:
\usepackage{graphicx, epsfig}
\usepackage{graphics}
\usepackage{subfiles}
\begin{document}
\newcommand{\main}{.}
\subfile{chapter1/chapter1.tex}
\end{document}

chapter1.tex
\documentclass[../main.tex]{subfiles}
\providecommand{\main}{..}
\begin{document}
\includegraphics[width=0.6\textwidth]{\main/figures/chapter1/figure.jpg}
{document}

#Latex Break Long Equation | Rumus Panjang

There are many ways to break a long equation in Latex. The simple way is using the mathtools package. The example of Latex code as follows:

Suppose that we have following equation:

X=x_1+x_2+x_3+x_4+x_5+x_6


\usepackage{mathtools}
\begin{equation*}
X=
\begin{split} x_1+x_2+x_3+ \\ x_4+x_5+x_6\end{split}
\end{equation*}

Or …


\usepackage{mathtools,breqn}
\begin{dmath*}
X=
%
\begin{split} x_1+x_2+x_3+ \\ x_4+x_5+x_6 \end{split}
\end{dmath*}

The output
equation

Drawing With #latex

\begin{figure}
\centering
\begin{tikzpicture}
\tikzstyle{main}=[circle, minimum size = 3mm, thick, draw =black!80, node
distance = 12mm]
\tikzstyle{connect}=[-latex, thick]
\tikzstyle{box}=[rectangle, draw=black!100]
\node[main,
\node[main,
\node[main]
\node[main]
fill = white!100] (a) [label=left:$a$] { };
fill = white!100] (b) [right=of a,label=left:$b$] { };
(p) [below=of a,label=left:$p$] { };
(ei) [below=of p,label=left:$e_i$] { };
\node[main,fill = white!100] (alpha_E) [right=of b,label=left:$\alpha_E$] { };
\node[main,fill = white!100] (alpha_Edash) [right=of alpha_E,label=left:
$\alpha_{E'}$] { };
\node[main] (pie) [below=of alpha_E,label=left:$\pi_E$] {};
\node[main] (ze) [below=of pie,label=left:$z_{Ei}$] {};
\node[main] (piedash) [below=of alpha_Edash,label=left:$\pi_{E'}$] {};
\node[main] (zedash) [below=of piedash,label=left:$z_{E'i}$] {};
\node[main,fill = black!10] (xi) [below=of zedash,label=below:$x_i$] {};
\node[main, fill = white!100] (lambdae) [right= of piedash,label=left:
$\lambda_E$] { };
\node[main] (thetaek) [below= of lambdae,label=below:$\theta_{Ek}$] { };
\node[main, fill = white!100] (lambdaedash) [right= of lambdae,label=left:
$\lambda_{E'}$] { };
\node[main] (thetaekdash) [below= of lambdaedash,label=below:$\theta_{E'k}$]
{ };
\path (a) edge [connect] (p)
(b) edge [connect] (p)
(p) edge [connect] (ei)
(ei) edge [connect] (xi)
(alpha_E) edge [connect] (pie)
(alpha_Edash) edge [connect] (piedash)
(pie) edge [connect] (ze)
(piedash) edge [connect] (zedash)
(ze) edge [connect] (xi)
(zedash) edge [connect] (xi)
(lambdae) edge [connect] (thetaek)
(lambdaedash) edge [connect] (thetaekdash)
(thetaek) edge [connect] (xi)
(thetaekdash) edge [connect] (xi)
;
\node[rectangle, inner sep=0mm, fit= (ei) (ze) (zedash) (xi),label=above
right:N, xshift=16mm] {};
\node[rectangle, inner sep=5.4mm,draw=black!100, fit= (ei) (ze) (zedash) (xi)]
{};
\node[rectangle, inner sep=0mm, fit= (thetaek),label=above right:$\infty$,
xshift=0.0mm] {};
\node[rectangle, inner sep=5.4mm, draw=black!100, fit = (thetaek)] {};
\node[rectangle, inner sep=0mm, fit= (thetaekdash),label=above right:$\infty$,
xshift=0.0mm] {};
\node[rectangle, inner sep=5.6mm, draw=black!100, fit = (thetaekdash)] {};
\end{tikzpicture}
\caption{}
\label{fig:inf-model-structure}
\end{figure}

Result :
latexdraw
Credits: Vinod Hegde

[Latex] Banyak File dengan subfiles

Instalasi

wget http://mirror.ctan.org/macros/latex/contrib/subfiles.zip
unzip subfiles.zip
cd subfiles
latex subfiles.dtx
latex subfiles.ins

dokumen utama.tex

\documentclass{book}
\usepackage{subfiles}
\begin{document}
\subfile{bab1}
\end{document}

bab1.tex

\documentclass[utama.tex]{subfiles}
\begin{document}
\chapter{bab 1}
\end{document}

kopi subfiles.sty dan subfiles.cls ke dalam folder dimana utama.tex berada

[Latex] Banyak Gambar Tanpa Subfigure

Menampilkan banyak gambar dalam satu baris bisa kita lakukan dengan subfigure. caranya sama dengan postingan saya tentang banyak tabel
Sayang dengan subfigure, kurang pas untuk kasus saya sekarang, Penginnya captionnya beda 🙂 . Setelah ublek2 dapatlah cara pakai minipage seperti dibawah ini

\begin{figure}
\centering
\begin{minipage}{.7\textwidth}
\centering
\includegraphics[width=.8\linewidth]{img/example.png}
\captionof{figure}{Gambar A}
\label{fig:A}
\end{minipage}%
\begin{minipage}{.7\textwidth}
\centering
\includegraphics[width=.8\linewidth]{img/example.png}
\captionof{figure}{Gambar B}
\label{fig:B}
\end{minipage}
\end{figure}

Hasil dari kode latex diatas :

minipage

bandingkan hasilnya jika menggunakan subfig :

subfig