1

How can I get a small box at the right hand side of the document as in the figure below: enter image description here

My initial attempt failed:

\begin{flushright}
\begin{tcolorbox}
\textbf{Date:11/12/2018}\\
\textbf{Time: 2:30 PM}
\end{tcolorbox}
\end{flushright}

Thank you.

  • 1
    Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Dec 7 '18 at 5:59
3

You can specify the text width=3cm, or use tcbox{} along with a table:

enter image description here

Notes:

  • The showframe package was used just to show the page margins. It is not needed in your actual use case.

Code:

\documentclass{article}
\usepackage{showframe}
\usepackage{tcolorbox}

\begin{document}

\begin{flushright}
    \begin{tcolorbox}[text width=3cm]
        \textbf{Date:11/12/2018}\\
        \textbf{Time: 2:30 PM}
    \end{tcolorbox}
\end{flushright}

\begin{flushright}
\tcbox[left=2pt,right=2pt]{%
    \bfseries
    \begin{tabular}{@{}ll@{}}
        Date: & 11/12/2018 \\
        Time: & 2:30 PM    \\
    \end{tabular}%
}%
\end{flushright}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.