# Computing functions and simultaneously produce markup language

**URL:** <https://community.wolfram.com/t/computing-functions-and-simultaneously-produce-markup-language/21474>\
**Category:** Questions\
**Tags:** physics, symbolic-computations, units\
**Created:** [January 23, 2023, 6:58pm UTC](https://community.wolfram.com/t/computing-functions-and-simultaneously-produce-markup-language/21474 "2023-01-23T18:58:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![egdexc87](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@egdexc87](https://community.wolfram.com/u/egdexc87)\
**Post date:** [January 23, 2023, 6:58pm UTC](https://community.wolfram.com/t/computing-functions-and-simultaneously-produce-markup-language/21474/1 "2023-01-23T18:58:14Z")

</div>

My goal is to have all values and units show on both sides of the equation in traditional form. As and example I am using coulomb’s law to calculate the magnitude of an electric field for specific distances. At the same time I am trying to create markup language level text and outputs for reporting and sharing. This is just a simple example. However the main divisor line seems to have a mind of its own (undefined behavior? or I’m just new at this). Here is my take on the example with the second to last output being close but not good enough:

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/f965f5d9-b271-4d3a-85ec-20e163bdef5c)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [January 24, 2023, 10:39am UTC](https://community.wolfram.com/t/computing-functions-and-simultaneously-produce-markup-language/21474/2 "2023-01-24T10:39:58Z")

</div>

Maybe something like this:

```
questionP21 = 
 HoldForm[((v) ((cc)*2*r5bis/((r3) + (r4))))*((1/
       Sqrt[(r3) + (r4)]))] /. {v -> valke, cc -> convertC, 
   r5bis -> r5}

```

---

<div class="post-metadata">

**Author:** ![egdexc87](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@egdexc87](https://community.wolfram.com/u/egdexc87)\
**Post date:** [January 24, 2023, 5:11pm UTC](https://community.wolfram.com/t/computing-functions-and-simultaneously-produce-markup-language/21474/3 "2023-01-24T17:11:15Z")

</div>

Thank you Gianluca, This does get my result a lot closer, the divisor line now spans the whole section, however the denominators do not show their values just the variable names . Could you explain what your intuition was so I can repeat the process? Thank you.

---

<div class="post-metadata">

**Author:** ![eric3](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/eric3/32/12760_2.png) [@eric3](https://community.wolfram.com/u/eric3)\
**Post date:** [January 24, 2023, 6:22pm UTC](https://community.wolfram.com/t/computing-functions-and-simultaneously-produce-markup-language/21474/4 "2023-01-24T18:22:00Z")

</div>

That’s just because Gianluca didn’t add replacement rules for `r3` and `r4`. You could easily add those.

You might actually get more flexibility with a template:

```
equationTemplate = 
 TemplateExpression[((TemplateSlot[
        "valke"]) ((TemplateSlot["convertC"])*2*
        TemplateSlot[
          "r5"]/((TemplateSlot["r3"]) + (TemplateSlot["r4"]))))*((1/
       Sqrt[(TemplateSlot["r3"]) + (TemplateSlot["r4"])])) == 
   TemplateSlot["answer"]]

```

Then you apply the template:

```
TemplateApply[equationTemplate, <|"valke" -> valke, "r3" -> r3, 
  "r4" -> r4, "r5" -> r5, "convertC" -> convertC, 
  "answer" -> answerP21|>, InsertionFunction -> HoldForm]

```

With this approach, you decouple your values from your format. For example, if you don’t like the look of `0.25 m^2 + 0.25 m^2` and would like those to automatically combine, you could change your template thus:

```
equationTemplate = 
 TemplateExpression[((TemplateSlot[
        "valke"]) ((TemplateSlot["convertC"])*2*
        TemplateSlot["r5"]/(TemplateSlot["r3+r4"])))*((1/
       Sqrt[TemplateSlot["r3+r4"]])) == TemplateSlot["answer"]]

```

and then add another rule in your application:

```
TemplateApply[equationTemplate, <|"valke" -> valke, "r3" -> r3, 
  "r4" -> r4, "r5" -> r5, "convertC" -> convertC, 
  "answer" -> answerP21, "r3+r4" -> r3 + r4|>, 
 InsertionFunction -> HoldForm]

```

---

<div class="post-metadata">

**Author:** ![egdexc87](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@egdexc87](https://community.wolfram.com/u/egdexc87)\
**Post date:** [January 24, 2023, 7:41pm UTC](https://community.wolfram.com/t/computing-functions-and-simultaneously-produce-markup-language/21474/5 "2023-01-24T19:41:56Z")

</div>

Great solution Eric. I was able to complete the results and thank you for the intuition so I can apply this to future work.
