# Side Text box placing

I am new to latex. Can't figure out how to put a side text box. I tries using \usepackage{wrapfig} but as it is inside enumerate it can't be done.

Here is an image of what I want to do. left one is done with ms word and right one with LaTeX.

Here's a part of the code (not same as the image, just putting it so you can know what packages I am using).

% !TEX program = xelatex
\documentclass[11pt]{article}

\setcounter{secnumdepth}{0}
\usepackage{polyglossia}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{enumerate}
\usepackage[version=4]{mhchem}
\usepackage{chemfig}
\setchemfig{atom sep=4ex}
\usepackage{xfrac}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{quotes,angles}

\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}

\setmainlanguage[numerals=Devanagari]{bengali}
\setotherlanguage{english}
\newfontfamily\englishfont{Times New Roman}
\newfontfamily\bengalifont[Script=Bengali]{Kalpurush}

\newcommand{\drg}{^{\circ}}
\newcommand{\bd}{\textbf}
\newcommand{\eng}{\textenglish}

\title {\eng{Physic Formulas}}
\author{সোয়েব পারভেজ জীম}
\date{28 February 2020}
\begin{document}

\maketitle

\begingroup
\tableofcontents
\endgroup

\thispagestyle{empty}
\clearpage\mbox{}\thispagestyle{empty}\clearpage

\section{\eng{Physic 1${}^{st}$ Paper}}

\subsection{২য় অধ্যায়}

\begin{enumerate}[ wide=0em, label=\textenglish{\textbf{ \arabic* .}}, itemsep=0pt, parsep=1ex]
\item ভেক্টরের লব্ধি $R=\sqrt{P^2+Q^2+2PQcos\alpha }$

\item  লব্ধি $R$ ও কোনো ভেক্টর $P$ এর মধ্যবর্তী কোণ $\theta ={{\mathrm{tan}}^{-1} \left(\dfrac{Qsin\alpha }{P+Qcos\alpha }\right)\ }$

\item  $\overrightarrow{P}$ ও $\overrightarrow{Q}$ এর লব্ধি $\overrightarrow{R}$ হলে,
$\dfrac{P}{{\mathrm{sin} \beta \ }}=\dfrac{Q}{{\mathrm{sin} \alpha \ }}=\dfrac{R}{{\mathrm{sin} \left(\alpha +\beta \right)\ }}$

\item  $A=A_x\hat{i}+A_y\hat{j}+A_z\hat{k}$ হলে $\left|A\right|=\sqrt{A^2_x+A^2_y+A^2_z}\$

\item  ডট গুনণ $\overrightarrow{A}\cdot \overrightarrow{B}=AB{\mathrm{cos} \theta }=A_xb_x+A_yb_y+A_zB_z$

\item  তিনটি ভেক্টর একই তলে হবে যদি $\overrightarrow{A}\left(\overrightarrow{B}\times \overrightarrow{C}\right)=0$
\end{enumerate}

• Welcome to tex.stackexchange! – TivV Feb 28 '20 at 21:58

This answer explains why it is difficult placing a float in an enumerate environment (for this and other reasons it is probably not the most elegant solution to have an enumerate environment span the whole page).

You could increase the right margin and place a tcolorbox inside a marginpar, in which case the box can not overlap with the enumerate environment:

\documentclass{article}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{tcolorbox}
\usepackage[right=7cm]{geometry} %just an example margin

\newcommand{\parinfobox}[1]{
\marginpar{
\begin{minipage}{130pt}#1\end{minipage} %same goes for this width
}
}
}

\begin{document}
\begin{enumerate}
\item Some
\item ample
\item sample
\item $\dfrac{P}{{\mathrm{sin} \beta \ }}=\dfrac{Q}{{\mathrm{sin} \alpha \ }}=\dfrac{R}{{\mathrm{sin} \left(\alpha +\beta \right)\ }}$
\item ample \parinfobox{Infobox with some text in it.\\You can break lines too.

\begin{enumerate}[leftmargin=*]
\item First item
\item $\theta ={{\mathrm{tan}}^{-1} \left(\dfrac{\sin\alpha }{\cos\alpha }\right)\ }$
\end{enumerate}}
\item sample
\end{enumerate}
\end{document}


Here \parinfobox{⟨content⟩} places the content inside a minipage in the tcolorbox in the page margin.

Alternatively, when not using an enumerate list that spans the entire page, you could use a more conventional box, here an example tcolorbox:

\documentclass{article}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{wrapfig}
\usepackage{tcolorbox}

\newcommand{\infobox}[2]{
\begin{wrapfigure}{r}{0pt}
\begin{tcolorbox}[colframe=green!50!white,colback=white,width=#1]#2\end{tcolorbox}
\end{wrapfigure}
}

\begin{document}
Some ample sample text some ample sample ample sample text.
Some ample sample text some ample sample ample sample text.
Some ample sample text some ample sample ample sample text.

\infobox{.5\textwidth}{Infobox with some text in it.\\You can break lines too.

\begin{enumerate}[leftmargin=*]
\item First item
\item $\theta ={{\mathrm{tan}}^{-1} \left(\dfrac{\sin\alpha }{\cos\alpha }\right)\ }$
\end{enumerate}
}

Some ample sample text some ample sample ample sample text.
Some ample sample text some ample sample ample sample text.
Some ample sample text some ample sample ample sample text.
\end{document}


It provides the command \infobox{⟨width⟩}{⟨content⟩} that places a tcolorbox inside a wrapfig with a width of your choosing. It will be placed approximatley at the right hand margin of where in the text you put \infobox{}{}.

Even though it's a wrapfigure you should be careful with it's placement, because it can still interfere with running text in undesired ways.

You can of course style the box to your liking with the many options tcolorbox provides (for example you could give the boxes titles, or number them), as well as change the placement etc. of the wrapfigure (for example you could make them overhang into the right margin a bit if they get into the way too often).

• Hi, for my humble opinion it is more beautiful to use \sin and \cos math commands. – Sebastiano Feb 28 '20 at 22:15
• I just copied a random part of OPs math – TivV Feb 28 '20 at 22:16
• I agree though, it does look more beautiful, I changed it now :) – TivV Feb 28 '20 at 22:21
• Thank you very much for your response. But if I am not wrong, may be warpfig can't be inside enumerate. I was really thinking to include that box at side of a list. – Soyeb Jim Feb 28 '20 at 22:57
• @SoyebJim You are completely right! I misread your question as "I want to place an enumerate in my side box". It is tricky to do if your whole document is one huge enumerate list (see here for an explanation why)... I can only think of placing your boxes inside the right page margin with a kind of \marginpar. – TivV Feb 28 '20 at 23:32