Common format options - mkraska/meclib GitHub Wiki

Suppress multiplication sign and displayed fractions

Note that you can globally set the multiplication sign to "none" in the question options. This is how to do it locally:

{@ (make_multsgn("blank"), a*b) @}

$ab$ instead of $a\cdot b$

{@ (stack_disp_fractions("i"), 1/x) @} 

$1/x$ instead of $\frac{1}{x}$

{@ (make_multsgn("blank"), stack_disp_fractions("i"), a*b/x) @}

$ab/x$ instead of $\frac{a\cdot b}{x}$

Display of values with units

Declare units:

stack_unit_si_declare(true);

If you just display the variable, then it can happen, that a numerical value of 1 is cancelled, i.e. you get $\mathrm{m}$ instead of $L=1\,\mathrm{m}$.

If L is defined as L: 1*m, then display the value using

{@'L=stackunits(L/m, m)@} (results in $L=1\,\mathrm{m}$).

If you want to change the unit locally in the display, then use

{@'L=stackunits(stack_unit_si_to_si_base(r1/cm), cm)@} (results in $L=100\,\mathrm{cm}$).

Lists without brackets

In ordinary question text. This creates a string, which can be displayed using \({@...@}\) (results in $a,b,c_12$).

stack_disp_comma_separate([a,b,c_12])

In castext-expressions use a helper function from fb_value.mac. This creates a castext()-expression, which can be displayed using {@...@} (results in $a,b,c_{12}$).

fb_strip_list(listify([a,b,c_12])
ct_c_s_md(_L):= if length(_L) = 0 then "" else if length(_L) = 1 then castext("{@_L[1]@}",md) else (
 lreduce(castext_concat, rest(join(makelist(castext("{@_Li@}",md),_Li,_L), makelist(", ",length(_L))),-1))
);
ct_c_s(_L):= if length(_L) = 0 then "" else if length(_L) = 1 then castext("{@_L[1]@}") else (
 lreduce(castext_concat, rest(join(makelist(castext("{@_Li@}"),_Li,_L), makelist(", ",length(_L))),-1))
);
{@ct_c_s_md([a,b,c_12])@}

<p>{@ct_c_s([a,b,c_12])@}</p>

Both versions produce $a,b,c_{12}$ in a Markdown castext region.