I got a problem with formatting text in math mode. I made a commmand that moves the unit in the end of the equations all the way to the right. It looks like that
\newcommand{\unit}[1]{\hfill{\text{#1}}}
And this is how I intended to use it (just some random equation):
\begin{equation}
p(P)=S_{\text{i}}+10\cdot \log_{10}\left(\frac{P}{1\:\text{W}}\right)\,\unit[{dB}_{SPL}]
\end{equation}
And this is how it looks:
And now to the problem. As you can se the unit is italic but I would like to be normal (roman). I can do this if I type it manually every time I add a new unit but I would like it to automatic.
I have tried to use:
\mbox
\mathrm
\normalfont
\text
\textrm
Here is some more info you might need to help me:
\documentclass[a4paper,11pt,fleqn,dvipsnames,twoside,openright]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage[T1]{fontenc}
\usepackage{ragged2e,anyfontsize}
\usepackage{fixltx2e}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{stmaryrd}
\usepackage{amsthm}
\usepackage{textcomp}
\usepackage{siunitx}
\sisetup{output-decimal-marker = {,}}
\newcommand{\e}{\text{e}}
%THE newcommand which is causing problems!%
\newcommand{\enhed}[1]{\hfill{\text{#1}}}
\hyphenation{}
siunitx
? You are loading it, why not use it here? Does something like\si{db_{SPL}}
not work?\unit[{dB}_{SPL}]
the argument of\unit
is just[
the other characters are just set in the surrounding math expression