# Creating a macro which draws rectangle on the edge of the paper

How can I write the following macro to compile in XeLatex

The Paper to be divided into two columns by using a borderless table (middle | is for conceptualization purpose only. it will not be visible)

1. A colored rectangle should appear on the Edge of the paper (actually right hand edge of the table which will be on Right hand Edge of the paper)

2. text 1 should start from the top right corner of the rectangle. text 2 should appear on the same line but appear in the left hand side of the column

3. Text 3 little bit bigger in font should appear in the middle of text 1 and text 4, relatively to the middle of the rectangle

4. Text 4 should appear near the bottom of the rectangle

"Desciption" should start just after the end of the rectangle, leaving the width of the rectangle from the right. description text should follow in the next lines

vspace 6 pt

End of Macro

Here it is what I am trying to achieve:

• Would text 1 to 4 extend for several lines each, of fit on a single line? – Bernard Jul 8 '16 at 11:52
• Single Line as in the picture. only the text below the description is free form might flow 2 or 3 lines. – Curi0usM3 Jul 8 '16 at 12:13

Here is a solution, with a macro \rectonedge with 5 arguments. It is based on a patched version of the leftbarenvironment, from the framed package and the geometry package. The part with the rectangle should break across pages if necessary:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{gillius2}
\usepackage[showframe,  verbose]{geometry}
\usepackage{lipsum, framed, xcolor, tabularx, setspace}

\makeatletter
\newenvironment{myleftbar}{%
\def\FrameCommand{\hskip-\Gm@lmargin\color{red}\vrule width\Gm@lmargin\color{black}}%
{\endMakeFramed}
\makeatother

\newcommand\rectonedge[5]{%
\begin{myleftbar}
\noindent\begin{tabularx}{0.45\linewidth}{X@{}}
#1 \hfill #2\\[1cm]
\textbf{\LARGE#3} \\[1cm]
\textbf{\Large#4}
\end{tabularx}
\end{myleftbar}
\noindent\parbox{0.45\linewidth}{\bfseries\textcolor{red}{Description}\smallskip\\#5\vskip11pt}
\newline%
}%

\begin{document}

\sffamily

\rectonedge{text1}{text2}{TEXT3Bold}{Text4}{Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique,
libero. Vivamus viverra fermentum felis.}
\lipsum[2]

\end{document}