# Creating a box containing a picture

## Goal

I am trying to replicate creating the box under

## Attempt

So far what I have managed to do is this

However my solution feels very hackish, the image is not in the correct position, the box is not properly centered and the lines are not propperly spaced. Is there a better way to produce a result similar to what was done above?

## Code

I think I used this image in my code

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

\usepackage{ctable} % for \specialrule command
\usepackage{tabularx} % in the preamble
\usepackage{fullpage}
\usepackage{multirow}

\usepackage{svg}

\begin{document}

\begin{tabularx}{\textwidth}{|X r|}
\specialrule{.1em}{.05em}{.05em} \hline & \\

\multirow{3}{*}{\includegraphics[height=2.5cm]{NTNU.png}} & \huge TMA4140 \\[0.2em] & \huge Diskre Matematikk \\[0.2em] & \huge Høst 2017 \\
& \\ & \\ & \\
\large Norges teknisk-vitenskapelige & \\
\large universitet & \textbf{Løsningsforslag --- Øving 1}\\
\large Insitutt for matematiske fag & \\
\hline \specialrule{.1em}{.05em}{.05em}
\end{tabularx}

\end{document}


With some low level tricks (logo from Alenanno's answer):

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

\definecolor{mblue}{RGB}{0,72,161}

\newcommand{\ntnulogo}{%
\leavevmode
\vtop{
\hrule height 0pt
\hbox{%
\begin{tikzpicture}
\fill[mblue, rounded corners=5mm] (0,2) rectangle (2,4);
\fill[white] (0.5,2.5) rectangle (1.5,3.5);
\fill[mblue] (1,3) circle (4mm);
\end{tikzpicture}%
}
}
}
\newcommand{\course}{%
\leavevmode
\vtop{\LARGE
\hrule height 0pt
\ialign{\hfil##\cr
TMA4140 Diskret\cr
Matematikk\cr
Høst 2017\cr
}%
}%
}

\begin{document}

\begin{center}
\setlength{\fboxsep}{0pt}
\fbox{%
\begin{minipage}{\dimexpr\textwidth-2\fboxrule}
\vspace{1pt}
\hrule height 1pt
\vspace{6pt}
\begin{tabular}{@{}l@{}}
Norges teknisk-vitenskapelige\\
universitet\\
Insitutt for matematiske fag
\end{tabular}\hfill
\vspace{3pt}
\hrule height1pt
\vspace{1pt}
\end{minipage}%
}
\end{center}
\end{document}


I suppose there's more than one approach to do this, I love TikZ though so here's one solution using this package.

## Code

\documentclass[margin=1cm]{standalone}
\usepackage{tikz}
\usepackage[utf8]{inputenc}

\definecolor{mblue}{RGB}{0,72,161}

\begin{document}
\begin{tikzpicture}

\fill[mblue, rounded corners=5mm] (0,2) rectangle (2,4);
\fill[white] (0.5,2.5) rectangle (1.5,3.5);
\fill[mblue] (1,3) circle (4mm);

\node[outer sep=0, inner sep=0, anchor=north west, text width=12cm] (bt) at (0,1.8) {%
Norges teknisk-vitenskapelige\\
universitet\hfill\textbf{Løsningsforslag --- Øving 1}\\
Insitutt for matematiske fag
};

\node[outer sep=0, inner sep=0, anchor=north east, text width=4cm, align=right, font=\Large] at (12,4) {%
TMA4140 Diskret\\
Matematikk\\
Høst 2017
};

\end{tikzpicture}
\end{document}

• That looks amazing! Any idea if it is possible to create the surrounding box in tikz as well? Jan 16 '18 at 23:05
• @N3buchadnezzar Sure, you can add \usetikzlibrary{calc} for some basic calculations, then name the last node (tp) and then add a line at the bottom: \draw ($(bt.south west)+(-.5,-.5)$) rectangle ($(tp.north east)+(.5,.5)$); et voilà. Jan 16 '18 at 23:22