5

picture

I want the row kandidatnivå, 15 hp to be aligned to left with examensarbete nr. xxx. How do I solve this?

\begin{minipage}[t]{0.48\textwidth} \scriptsize
Institutionen för Fastigheter och Byggande\\
Civilingenjör Samhällsbyggnad\\
Fastighetsekonomi och fastighetsjuridik
\end{minipage}
\hfill
\begin{minipage}[t]{0.48\textwidth} \scriptsize
\begin{flushright}
Examensarbete  nr. xxx\\
Kandidatnivå, 15 hp
\end{flushright}
\end{minipage}
  • 1
    Welcome to TeX.SE. Wrap the text within \begin{tabular}[t]{l@{}}...\end{tabular}. You also need a \noindent before the first minipage. Add \usepacakge{showframe} to see the effect. Also, while code snippets are useful in explanations, it is always best to compose a fully compilable MWE that reproduces the problem including the \documentclass and the appropriate packages. – Peter Grill May 21 '14 at 21:47
2

For a flushed view on both ends, you can use the following tabular specification:

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}

\noindent
{\scriptsize%
\begin{tabular}[t]{@{}l}
  Institutionen för Fastigheter och Byggande \\
  Civilingenjör Samhällsbyggnad \\
  Fastighetsekonomi och fastighetsjuridik
\end{tabular}
\hfill
\begin{tabular}[t]{l@{}}
  Examensarbete  nr. xxx \\
  Kandidatnivå, 15 hp
\end{tabular}%
}
\end{document}

For a 50/50 split of the two boxes (one on the left half of the page and one on the right half), both with a left alignment, use the following tabular specification:

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}

\noindent
{\scriptsize%
\begin{tabular}[t]{@{}p{.5\linewidth}@{}}
  Institutionen för Fastigheter och Byggande \\
  Civilingenjör Samhällsbyggnad \\
  Fastighetsekonomi och fastighetsjuridik
\end{tabular}%
\begin{tabular}[t]{@{}p{.5\linewidth}@{}}
  Examensarbete  nr. xxx \\
  Kandidatnivå, 15 hp
\end{tabular}%
}
\end{document}

Of course, other alignments are also possible, depending on your setup.

2

For such things, defining a command is better, as it allows for easier input. It also allows for easily changing the output format. Here's an example:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[pass,showframe]{geometry} % just to show the page frame

\newcommand{\topinfo}[2]{%
  \begingroup\scriptsize\noindent
  \begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}l@{}}
  \begin{tabular}[t]{@{}l@{}}
  #1
  \end{tabular}
  &
  \begin{tabular}[t]{@{}l@{}}
  #2
  \end{tabular}
  \end{tabular*}\par\endgroup
}

\begin{document}

\topinfo{
  Institutionen för Fastigheter och Byggande\\
  Civilingenjör Samhällsbyggnad\\
  Fastighetsekonomi och fastighetsjuridik
}{
  Examensarbete  nr. xxx\\
  Kandidatnivå, 15 hp
}

\end{document}

enter image description here

Should you like to change the fontsize, you'd need to modify just the definition, leaving the input in \topinfo exactly the same.

1

Two left-aligned \Longunderstacks can achieve this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[usestackEOL]{stackengine}
\begin{document}

\noindent
{\scriptsize%
\Longunderstack[l]{
  Institutionen för Fastigheter och Byggande \\
  Civilingenjör Samhällsbyggnad \\
  Fastighetsekonomi och fastighetsjuridik
}
\hfill
\Longunderstack[l]{
  Examensarbete  nr. xxx \\
  Kandidatnivå, 15 hp
}%
}
\end{document}

enter image description here

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.