Showing posts with label LATEX. Show all posts
Showing posts with label LATEX. Show all posts

Saturday, April 20, 2024

Menulis Source Code Latex

 \usepackage{verbatim} %menulis sourcecode
\usepackage{listings} %menulis sourcecode
\usepackage{xcolor}%menulis sourcecode
%---
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
%===
\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},   
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=b,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=2
}
\lstset{style=mystyle}
%---

\begin{lstlisting}[language=python, caption=Regresi Linier HP dan Kamera]
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression

df = pd.DataFrame([[8,7],[2,3],[6,7],[4,2],[7,8],[3,3]])
df.columns = ['x', 'y']

x_train = df['x'].values[:,np.newaxis]
y_train = df['y'].values

lm = LinearRegression()
lm.fit(x_train,y_train) # fase training

print('Coefficient : ' + str(lm.coef_))
print('Intercept : ' + str(lm.intercept_))

x_test = [[170],[171]] # data yang akan diprediksi
p = lm.predict(x_test) # fase prediksi
print(p) # hasil prediksi

# prepare plot
pb = lm.predict(x_train)
dfc = pd.DataFrame({'x': df['x'],'y':pb})

plt.scatter(df['x'],df['y'])
plt.plot(dfc['x'],dfc['y'],color='red',linewidth=1)
plt.xlabel('kamera')
plt.ylabel('harga')
plt.show()
\end{lstlisting}

Monday, November 20, 2023

Dua Gambar Bersisian Pada LaTeX

 %--------DUA GAMBAR BERSISIAN

\begin{figure}
  \begin{minipage}{0.4\textwidth}
    \centering
    \includegraphics[width=\linewidth]{topologi-1-2023.drawio.png}
    \caption{Topologi Mesh 1 singgle Hop}
    \label{fig:topologi1}
  \end{minipage}%
  \begin{minipage}{0.5\textwidth}
    \centering
    \includegraphics[width=\linewidth]{topologi-2-2023.drawio.png}
    \caption{topologi 2 multiHop}
    \label{fig:topologi2}
  \end{minipage}
\end{figure}




Sunday, January 8, 2023

Membuat Beberapa Gambar pada Latex

\usepackage{caption}
\usepackage{subcaption}


\begin{figure}[ht]
    \centering
     \begin{subfigure}[b]{0.6\textwidth}
     \centering
      \includegraphics[scale=0.55]{desc-pelanggan1.png}
      \caption{Menambahkan Kolom TipePelanggan}
      \label{fig: desc-pelanggan1}     
\end{subfigure}
\newline
\newline
%gambar 2
%\hfill
     \begin{subfigure}[b]{0.6\textwidth}
         \centering
         \includegraphics[scale=0.55]{alter-order1.png}
\caption{Merubah Kolom OrderDate menjadi TglPesan}
\label{fig: descorder1} 
     \end{subfigure}
\newline
\newline
%gambar 3
 \begin{subfigure}[b]{0.75\textwidth}
         \centering
         \includegraphics[scale=0.6]{urutan-kolom-tipepelanggan.png}
\caption{Merubah Urutan Kolom TipePelanggan}
\label{fig: alterpelanggan3} 
     \end{subfigure}
     \caption{Contoh Alter Tabel}
        \label{fig:alter-tabel}
    \end{figure}
%---



Tuesday, December 27, 2022

Membuat List pada LaTeX

 \usepackage{enumitem} 


\begin{enumerate}
  \item list yang akan menjadi no 1
  \item list yang akan menjadi no 2
\end{enumerate}



Wednesday, November 30, 2022

Insert Image LaTeX


Package yang digunakan:

\usepackage{graphicx}
\usepackage{wrapfig,lipsum}

%--------------------------------

\begin{figure}[h] 
\centering
\includegraphics[scale=0.5]{ESP32.jpg}
\caption{ESP32}
\label{fig: ESP32} 
\end{figure}
%---------------------------------

atau

\includegraphics[width=0.5\textwidth]{ESP32.jpg}


extensi dari file bisa juga tidak perlu disertakan.

Teks dan Gambar Bersisian

%------------------------------------------------

\begin{wrapfigure}{l}{0.25\textwidth}
\includegraphics[width=0.9\linewidth]{ttgo} 
\caption{Caption1}
\label{fig:wrapfig}
\end{wrapfigure}

%------------------------------------------------




Saturday, November 26, 2022

Center Chapter in Latex

 \documentclass[12pt,letterpaper,twoside]{book}
%------------------------------------------------------------------ 
%agar chapter ada di center
\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\centering}{\centering\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter} {0pt}{50pt}{40pt}
%------------------------------------------------------------------ 

\ begin{document}
\tableofcontents
\addcontentsline{toc}{chapter}{Chap 1.}
\chapter*{CHAP 1}
\chapter{CHAP 2}
\appendix
\chapter{Test appendix}
\ end{document}