Frequently asked questions - Math

    From The Document Foundation Wiki
    < Faq‎ | Math(Redirected from Faq/Math/UseKeywordsAsVariables)
    Other languages:


    How do I use a keyword like in as a variable name?

    in is a keyword in Math, which is a set operation expecting two arguments on the both sides (before and after), so put in the formula as is, it shows you a question mark indicating missing argument.

    When you need to put a name that is a keyword in Math, you have several options.

    When you want to use it as a text

    E.g., a comment inside a formula ... just put all your comment, including what would otherwise be keywords, into quotes: "this is text in quotes".

    When you want to use it as a function name

    Functions (e.g., sin) by default have non-italic font. Turning Math keywords into function names also easy and logical. E.g., you wanted a formula like in(a, b): typed that way, it would give you ¿(a, b). To get what you need, you use func keyword explicitly telling that what follows is a function name, and should not be treated otherwise: func in( a,b ).

    When you want to use it as a variable name

    Variables by default have italic font. Using keywords as variables is most tricky: there's no syntax like quotes or a keyword telling that what follows is a variable. So below are workarounds with discussion:

    1. Use ital func <keyword>, like V_{ital func in}. This would do the trick in the default configuration, when variables and functions differ only in italics. But (a) it is long, and (b) it will fail if you setup your formula fonts so that function names also use different font face: then italicized function name will still differ visually from variables. A variant of the same approach is uoper <keyword> {}, as in V_{uoper in {}} - but it seems to use the same font as variables, without need to specify ital explicitly.
    2. Use ital "keyword", like V_{ital "in"}. The shortest of all workarounds; still has the same problem as #1: if you change font of text in your formula, this workaround will not produce correct result.
    3. Use explicit font definition, using font Serif size 12 bold ital "in". Most verbose; allows you to match your customized font chosen for variables... but if you later decide to change formula fonts (e.g., using an extension allowing you to do it in all formulas at once), you will need to look through all your formulas with those workarounds and change that manually.
    4. Use nospace keyword, like in V_nospace {i n}. This takes the following separate elements and joins them - almost as if they are one word. Slightly longer than #2; but IMO, it's the best option, since it gives you the formatting of variables which you choose in the formula. Yes, still a workaround.