The command intended for this purpose is \mathrm.
The \DeclareMathOperator and \operatorname commands are intended for log-like operators such as log or cos. The \text command is intended for short passages of text in math mode, such as “$x$ is even” and “otherwise” next to cases. The \mathop command does not change the font or its kerning, although you can wrap \mathop{\mathrm #1}} to get operator-like spacing. The \mathit command is usually not visually distinct from the default math font, but it could be a valid stylistic choice.
Sans-serif fonts frequently have a different meaning:
Sans-serif upright characters may be used in technical and/or physical texts in order to mark objects that cannot be confused with mathematical symbols, for example for the names of points in the description of geometrical figures, technical objects, experimental setups, and the like. Therefore sans-serif upright letters never appear in a mathematical formula of a physicist or an engineer, while mathematicians use sans-serif fonts to represent certain structures in category theory. As a partial exception, sans-serif sloping uppercase letters are allowed to indicate tensors of the second rank,but this is the only exception mentioned [....]
Since that article appeared in TUGboat more than twenty years ago, things have changed, but most documents that would use sans-serif fonts for full-word variable names also use them as the main font throughout. Therefore, it’s semantically misleading to declare that you want to use the mathematical sans-serif font for this; you really want to use the mathematical upright font. If you copied and pasted the formula into another document, you would want it to be set in that document’s mathematical upright font, to match the rest of the document.
The unicode-math package defines one other option, \mathup. If backward-compatibility with legacy 8-bit fonts isn’t a concern, I prefer that over the other alternatives because it means, “The default upright font for mathematics, which might or might not be Roman, and can be distinct from the main text font you get with \text, the operator font, or the upright individual math symbols you get with \symup.”
In practice, I would typically declare a \newcomamnd for \mathop{\mathup{#1}} or \mathop{\mathrm{#1}}. Sometimes I’ve declared it as \mathop{\text{\scshape #1}} to get small caps. That lets me declare the semantics I want, within the body of the document, not a particular appearance that might change between documents. Editing a bunch of \mathrm commands to \mathsf or \text or \operatorname is tedious and error-prone. Much better to choose a self-explanatory command and define its appearance in the preamble.
\textis always wrong, it should never be used for something like this. Secondly, there is no strict policy on how to format these things. – daleif Apr 02 '19 at 10:07\textis wrong for this? Would it be the right thing for an\text{else}, e.g. in acasesenvironment? – sheß Apr 02 '19 at 10:08\text{name}in the statement of a theorem. – egreg Apr 02 '19 at 10:10\textit{text $\text{text}$ text}, what ever solution is used, should not change its apparence if used in say a theorem. – daleif Apr 02 '19 at 10:10\textthe correct way. When you got a hammer, everything looks like a nail. – daleif Apr 02 '19 at 10:12\text{else}is a textual comment, not a math variable.\textis only suppose to be used for textual comments – daleif Apr 02 '19 at 10:13\DeclareMathOperator(and the primitive\mathop) are (mostly) designed to change the spacing rather than the font. compare\log xwith\mathrm{log}xand\mathop{\mathrm{log}}x– David Carlisle Apr 02 '19 at 10:16\mathrmwould be my choice. The operator-related things are for spacing, as David notes, and anything that has a\text...in it is for written text (for example, it preserves text spacing, not math spacing; compare\textrm{na me}tp\mathrm{na me}). I exclude\mathitbecause of the math convention that single-letter variables are set in italic. By process of exclusion, we arrive at\mathrmwhich will, by the way, properly set in subscript mode. – Steven B. Segletes Apr 02 '19 at 11:02\mathrm, prefer\mathsfto set if as math in a sans serif font. I sometimes do this if the multi-character variable is an unreadable acronym, for example,\mathsf{BL}to signify "ballistic length". – Steven B. Segletes Apr 02 '19 at 11:41\newcommand\Var[1]{\mathrm{#1}}. – Ulrike Fischer Apr 02 '19 at 11:55\emph{}(or within a blockquote that is italized)? – sheß Apr 03 '19 at 08:40\emph{X}is not semantically the same. – daleif Apr 03 '19 at 08:55\emph{something $xyz$ something}. – sheß Apr 03 '19 at 08:57\emphis used in an already italic context, then it should give me italic bold, because sometimes, the default (un-italic) isn't that noticable. Now the question becauses, should the math then be boldified as well? This again depends on the contents and design of the document. If bold math does not have a special meaning in this document, there is no problem in boldifying the math (also applicable to sections etc). But it bold math has a special meaning, then it would be bad to randomly boldfy math. – daleif Apr 03 '19 at 09:03