I have a problem with boxes. I'd like to make it so that a box including 2 words align horizontally. So the first word is above the second word, in turn hopefully making the box smaller. This is what I have written so far:

\textbf{Elektriske komponenter}  & \textbf{Leverandør} & \textbf{Pris} & 
\textbf{Enhed} & \textbf{Antal} & \textbf{Sum i kr}

In which i'd like the ''Elektriske komponenter'' to be aligned, with ''Elektriske'' above ''komponenter'' in a box. I have created a table so far, but can't seem to find a solution, as to how to make words inside the box align like this.

  • 3
    Could you please (1) add a compilable example code not a description of your code and (2) a sketch of what your "boxes" would look like – user156344 May 20 '19 at 14:12
  • 1
    Welcome to TeX.SE. Please indicate whether you use a tabular environment and, if so, which column types you employ for 6 columns. – Mico May 20 '19 at 14:29

Something like this?

enter image description here

\usepackage[danish]{babel} % is this correct?
\newlength\mylen % define a length "variable"

% Compute required width of 1st column:
\begin{tabular}{@{} p{\mylen} *{5}{c} @{}}
\textbf{Elektriske komponenter}  & \textbf{Leverandør} &
\textbf{Pris} & \textbf{Enhed} & 
\textbf{Antal} & \textbf{Sum i kr} \\
| improve this answer | |
  • Why measuring? \textbf{\begin{tabular}[t]{@{}l@{}}Elektriske \\ komponenter\end{tabular}} will do the same without needing to measure. – egreg May 20 '19 at 15:09
  • @egreg — Thanks. Let’s see if the OP sees fit to provide some much-needed additional information about the setup of the (outer) tabular environment and about what kind of text will show up at n the first column. – Mico May 20 '19 at 15:41

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.