Mathcad Prime 2.0 How To: Labels

Formatting Labels in PTC Mathcad Prime 2.0

PTC Mathcad Prime 2.0 supports a feature called “Labels”. In this blog, I’d like to describe the motivation behind, benefits and nuances of this feature. For the “old-timers” I will reflect how it relates to a similar Mathcad 15.0 feature.

3-22-2013 1-42-23 PM

Background: Labels come from the well established convention in mathematics and engineering that uses different font styles for variables to imply their meaning. For example many papers and books will declare that … lowercase italic letters denote scalars, while bold letters denote vectors, etc. In such context, variable x and x will mean different things and readers will not mistake one for another. Specifically, x = x is expected to be false.

Labels to exactly that. They differentiate two items of the same name. There are many examples where two different values have the same name: variable e and constant e=2.718…, variable c and c (the speed of light), variable m and the unit m (meter).

m and c can be one of the most commonly used variables (after n, a and b respectively, though x is in a class of its own). With labels, Mathcad lets you use the names m, c, etc. without confusing them with built-in definitions of meter, speed of light, etc.

Here is how. A name, say m, is always defined with a specific label. If one defined m:=42 in their document, they will be defining variable m. Mathcad, on the other hand defines unit m as 1 meter. I will use m_variable and m_unit to explicitly state that. Thus, m_variable:=42 and m_unit:=1 meter have two different values and can coexist without interference. As a matter of fact, we could have called one m_variable, and other m_unit, but that’s what programmers, and not engineers, would do. To help readers differentiate Mathcad (just like textbooks do) uses different font styles: m for the variable and m for the unit. Users, of course can decide what style to use.

Specifically we render labeled names with different font attributes:

  • Style (bold, italic, underline)
  • Color
3-22-2013 1-45-20 PMand users can defined what these are for each of the available labels:

  • Variable
  • Unit
  • Constant
  • Function
  • System
  • Keyword

3-22-2013 1-44-23 PM

The “(none)” label. All defined names have labels, so what does “(none)” mean? This is just a (badly named — we fixed that in Prime 3.0) convenience for users. It would be very tedious to have to type m, and then select label unit (Ctrl+U) every time we want to refer to the unit of meter, even when no other m‘s are defined in the document. It would be even worse if one types m*30=, and then adds definition of m earlier in the document, to have to go and change m*30= to variable m*30=. This is what label “(none)” does. When referring to a name, user does not need to specify a label — they just need to type (say) m, and Mathcad will find the most recent definition of that name, and render the typed name (after the evaluation) with appropriate font style.

3-22-2013 1-41-12 PM

Relating to Mathcad 15.0. If you are converting documents from version 15.0 or earlier, you should understand that Labels are similar, but not identical to “math fonts” in Mathcad 15.0. Mathcad 15.0 uses math fonts (also called math styles) for formatting. This sometimes affects semantics which often caused confusion. In Mathcad 15.0 one can select font, font size, style and color. We reserved font and font size for a different feature coming up in Prime 3.0.

In Mathcad 15.0, each math font affects several aspects of formatting an equation. For example “Variables” style will affect names (variables) as well as operators in the entire worksheet, while “Constants” applies to numbers, but can be applied to names too. Sometimes you may end op with a number that Variable style, … You get the point. There is no clear way to map these styles to labels in Prime 2.0. If you are converting a document, that relies on math styles heavily, you will need to review the results. Annotations will indicate where there are potential differences you need to review.

Since, semantically, two names (identifiers) that have different labels are different, labels apply only to names. It would be confusing to have a number “23” with a Constant label, as  this would imply that there is possibly another meaning of “23” — something that I don’t think makes much sense.

This entry was posted in Best Practices, Mathcad, Mathcad A to Z, The Inside Scoop, Tips & Tricks and tagged , , , . Bookmark the permalink.

One Response to Mathcad Prime 2.0 How To: Labels

  1. seo says:

    Howdy! I simply want to give a huge thumbs up for the good data you may have right here on this post.
    I will likely be coming back to your blog for more soon.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s