Search In This Website

Rabu, 30 April 2025

How To Write A Code Block In Latex 1

Learning Objectives: For longer (multiline) chunks of fixed-format text and automatic line breaking or wrap text, use the \begin{Verbatim}[breaklines=true, breakanywhere=true] to start the Verbatim environment (note the capital V letter). 


1. Type this following Latex code for typing the source code block in Latex editor:

% !TEX TS-program = pdflatex

% !TEX encoding = UTF-8 Unicode

\documentclass[12pt,letterpaper]{article}

\usepackage{fancyvrb}

\usepackage{fvextra}

\renewcommand{\seriesdefault}{bx}

\renewcommand{\bfseries}{\Huge{}}


\begin{document}

\section{Notes}

\Huge{}

To use the Verbatim environment you have to add the following line to the preamble of your document: \verb!\usepackage{fancyvrb}! and \verb!\usepackage{fvextra}!


\begin{Verbatim}[breaklines=true, breakanywhere=true]


% !TEX TS-program = pdflatex

% !TEX encoding = UTF-8 Unicode

\documentclass[12pt,letterpaper]{article}

\begin{document}

\begin{verbatim}

Hello World

\end{verbatim}

\end{document}


\end{Verbatim}

\end{document}

2. Save file as CodeHighlightVerbatim1.tex

3. then build or typeset or compile the Latex code.


Output

Notes Remember the V capital letter in \begin{Verbatim}[breaklines=true, breakanywhere=true] and \end{Verbatim}.





write latex code, verbatim environment

Bibliography

https://www.overleaf.com/
https://www.sascha-frank.com/

Tidak ada komentar:

Posting Komentar