3

I'm trying to recreate a document template thats in a PDF, in one portion of it, I need to create a box with a word of text next to it, like so:Original

I've tried using functions like \fbox and \framebox, however the text on the left of it, which should be aligned at the top, ends up in the middle or the bottom. Like in this example:

\documentclass[a4paper]{article} 

\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[serbianc]{babel}

\begin{document}
Коментар:
\fbox{
    \begin{minipage}
    {0.7\linewidth}\hfill\vspace{5cm}
    \end{minipage}
}
\end{document}

My attempt

1
  • 1
    Use \begin{minipage}[t]
    – Bernard
    Mar 3, 2019 at 11:28

3 Answers 3

4

A solution with \framebox. Just in case you'd like the box to go automatically to the right margin, it's easy to do with the linegoal package, which measures the distance from its point of insertion to the right margin:

\documentclass[a4paper]{article}

\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{linegoal}
\usepackage[serbianc]{babel}

\begin{document}

Коментар:
\framebox[\linegoal][l]{\rule[-5cm]{0pt}{\dimexpr5cm+1ex}
}

\end{document} 

enter image description here

3

You should use [t] for the minipage. It's easier with \parbox, though. The setting to \fboxsep will make the box the exact specified dimensions.

\documentclass[a4paper]{article}

\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[serbianc]{babel}

\newcommand{\blankbox}[2]{% #1 = width, #2 = total height
  \begingroup
  \setlength{\fboxsep}{-\fboxrule}%
  \fbox{\parbox[t][#2]{#1}{\strut}}%
  \endgroup
}

\begin{document}

Коментар: \blankbox{0.7\linewidth}{5cm}

\end{document}

enter image description here

2

Add option [t] (top) to the minipage:

\documentclass[a4paper]{article} 

\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[serbianc]{babel}

\begin{document}
Коментар:
\fbox{
    \begin{minipage}[t]
    {0.7\linewidth}\hfill\vspace{5cm}
    \end{minipage}
}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .