# Left align text in \fbox

I would like text to be left-aligned in \fbox. I want Student Name and ID in the example below to be aligned next to the left vertical line. How can I do this?

\documentclass{article}
\begin{document}
\begin{center}
\fbox{\fbox{\parbox[b]{4.5in}{\centering

\begin{tabular}{l}

\hline\\

{\large{Student Name:}}\hspace{3in}\\[3ex]

\hline\\

\large{ID \#}: \hspace{2.1in}
\\[1ex]
\hline
\end{tabular}}}}
\end{center}
\end{document}


## 2 Answers

\documentclass{article}
\begin{document}
\begin{center}
\fbox{\fbox{%
\begin{tabular}{p{4.5in}}
\hline\\
{\large{Student Name:}}\hspace{3in}\\[3ex]
\hline\\
\large{ID \#}:
\\[1ex]
\hline
\end{tabular}}}
\end{center}
\end{document}


In your code, you are\centering a narrow table within a \parbox of 4.5in, therefore the tabular is not flush left. If you draw the \fboxes directly around the tabular and specify the column as p{4.5in}, the tabular will be flush left.

• Excellent! This is what I'm trying to do – Ahmed Matar Nov 6 '19 at 8:46
• But then the signature line is under the text, – Sveinung Nov 6 '19 at 8:53
• @Sveinung you are right, but I guess I wanted it more to look like a table – Ahmed Matar Nov 6 '19 at 13:13

You load array, and set a second fix width column. The line you draw with a \cline. The vertical space between the box lines and the tabular, you can adjust with some vertical space:

\documentclass{article}
\usepackage{array}

\begin{document}
\begin{center}
\fbox{\fbox{\parbox[b]{4.5in}{\centering

\medskip

\begin{tabular}{lwl{3in}}

{\large{Student Name:}}&\\[1ex]

\cline{2-2}\\

\large{ID \#}:&
\\[1ex]
\cline{2-2}
\vspace{-0.2ex}
\end{tabular}}}}
\end{center}
\end{document}

• Thank you, but I want it to be aligned to the left of the box – Ahmed Matar Nov 6 '19 at 8:41
• Just a moment, I will update – Sveinung Nov 6 '19 at 8:43