I have a litte problem with using the \frac command, because the text that is written before it, it will be spaced. How can i fix this? It is on purpuse that there is two lines of text one under the other. It can work if i dont have the \displaystyle in my equation (the second equation) but then it just looks small.
\documentclass[11pt]{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\usepackage{amsmath}
\usepackage{mathptmx}
\usepackage{fancybox}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\usepackage{array}
\usepackage{delarray}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{decorations.markings}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage{booktabs}
\usepackage[dvipsnames]{xcolor}
\usepackage[paperheight=11.693in,paperwidth=8.267in]{geometry}
\setmainfont{Times New Roman}
\setmathfont{Times New Roman}
\geometry{left=3.4cm}
\pagestyle{empty}
\begin{document}
\text{\textit{x} og \textit{y} er ligefrem proportionale} \hspace{1cm} \text{(8)} \hspace{0.5cm} $\textit{y}= \textit{k}\cdot\textit{x}$ \hspace{2cm} $\displaystyle \frac{\textit{y}}{\textit{x}}= \textit{k}$\\
\text{Proportionalitetsfaktor \textit{k}}
\end{document}


\documentclass{article} \usepackage{mathtools} \begin{document} [your code here] \end{document}.leqnoas one of the\documentclassoptions.