How to use Boxes in LaTeX (Latex Advanced Tutorial-07)

Опубликовано: 29 Сентябрь 2024
на канале: Chandra Has
25,390
141

This episode includes:
The way to use the following commands-
\mbox, \fbox, \makebox, \framebox, \colorbox, \fcolorbox, \doublebox, \ovalbox, and \shadowbox.
-------------------------------------------------------------------------



Copy the given codes:
--------------------------------------------------------------------------------------------------------
\documentclass[11pt,a4paper]{article}
\usepackage{xcolor,booktabs,mathptmx}
\usepackage[margin=1in]{geometry}
\usepackage[demo]{graphicx}

\usepackage{fancybox}

\author{Chandra Has\\ \color{red}[email protected]}\title{Boxes in \LaTeX}


\setlength{\fboxsep}{5pt} % adjust fbox, fcolorbox, fancybox frame separation
\setlength{\fboxrule}{5pt} % adjust fbox, fcolorbox, fancybox rule thickness

% custom box % works with \usebox{\mybox}
\newsavebox{\mybox}
\savebox{\mybox}[0.5\textwidth][c]{Chandra Has}



\begin{document}\maketitle\vskip1cm

% table for boxes
\begin{tabular}{l}
\toprule
Boxes \\
\midrule
\verb|\mbox{text}| and \verb|\hbox{text}| \\
\verb|\makebox[width][pos]{text}|\\
\verb|\fbox{text}|\\
\verb|\framebox[width][pos]{text}|\\
\verb|\raisebox{lift}[height][depth]{text}|\\
\verb|\parbox[pos][height][contentpos]{width}{text}|\\
\verb|\begin{minipage}[pos][height][contentpos]{width} text \end{minipage}|\\
\bottomrule
\end{tabular}\vskip5mm

% normal paragraph
There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly {\color{red}believable}. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't {\color{red}anything embarrassing} hidden in the middle of {\color{red}text}\par.

\noindent
\verb|\mbox|, \verb|\makebox[width][pos]{text}|, \verb|\fbox{text}|, \verb|\framebox[width][pos]{text}| \\

There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly \mbox{\color{red}believable}. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't \makebox[5cm][l]{\color{red}anything embarrassing} hidden in the middle of \fbox{\color{red}text}.\\

% pos: s, r, c, l
\noindent
% makebox and framebox
\makebox[5cm][c]{Chandra Has}
\framebox[5cm][c]{Chandra Has}

\clearpage
\begin{tabular}{ll}
\toprule
S. no. & Des. \\
\midrule
1 &
\includegraphics[width=0.25\textwidth]{imagefile} \\
\bottomrule
\end{tabular}\vskip5mm

% raisebox
\noindent\verb|\raisebox{lift}[height][depth]{text}|\\
\begin{tabular}{ll}
\toprule
S. no. & Des. \\
\midrule
1 &
\raisebox{-.5\height}{\includegraphics[width=0.25\textwidth]{imagefile}} \\
\bottomrule
\end{tabular}\vskip5mm

\noindent
% parbox
% pos: b,c, t, contentpos: t, s, c, b
\verb|\parbox[pos][height][contentpos]{width}{text}|

\parbox[b][25mm][c]{0.75\linewidth}{There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour}

% fbox with parbox
\fbox{\parbox[b][15mm][c]{0.75\linewidth}{There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour}}\\

% parbox side by side
\parbox[b][10mm][c]{0.45\linewidth}{There are many variations} \hfill
\parbox[b][15mm][c]{0.45\linewidth}{There are many variations \\ text}

% custom box
\usebox{\mybox}

\noindent
% fancybox
\doublebox{argument}\\

\ovalbox{argument}\\

\shadowbox{argument}

% colorbox
\colorbox{gray!80}{text}
\fcolorbox{red}{green!15}{text}


\end{document}

~-~~-~~~-~~-~
Watch: "How to Use Title Slide in Beamer Presentation (LaTeX Advanced Tutorial-11)"
   • How to Use Title Slide in Beamer Pres...  
~-~~-~~~-~~-~