# Correct formatting of step-by-step equation demonstrations in papers

Working on some journal paper, it has pseudocode-ish/equation-ish demonstrations of the way some equations play out, along with actual reference values in the example proper; along the lines of:

i = i + 1

i = 2

Note: please assume the actual demonstrations are much more complex than this and actually require the reference values.

What is the correct formatting here? I have had it suggested to me the first line should be underlined, whereas I find putting the reference value in brackets more obvious - like so:

i = i + 1 (i = 2)

with the bracketed content right-aligned. Suggestions?

• What is an `actual reference value`?
– user41207
Commented Jan 9, 2017 at 3:51
• @Roboticist In this context, the second line as noted. Commented Jan 9, 2017 at 6:18
• Would it be a comment in the actual code? Commented Jan 9, 2017 at 9:53
• @T.Verron No, just an on-the-fly display of actual variable values Commented Jan 11, 2017 at 0:05

I don't believe there is a correct way to do this, because you shouldn't put them together.

Writing i = i + 1 fully contains everything the reader should need to know about the statement. If you really want to lay out both a theoretical pseudocode notation and walk through an iteration, I would do them separately. One way might be something like:

``````for i in range(0, 10):
i = i + 1
print i
``````

In this step we print to the screen the numbers 1 through 10. For example, in the first iteration i takes on the value 0 from the first line, then has 1 added to itself. The third line then prints 1 to the screen.

This way your pseudocode is treated like a mathematical equation in a paper, indented or otherwise separate from regular text, then examples as you go are just included in the text. Depending on your audience and the complexity of the statements, you might also trust your audience to be able to parse your pseudocode without the need for filling in sample values. Feeling like you need to walk through an example with numbers might be a sign that your pseudocode needs improving.

In short, trying to mash them together as you're suggesting just seems confusing to me.

The huge, important caveat to what I suggest: look through the literature specific to your field and see how this is done elsewhere. If you can't find any examples of someone doing what you're asking about (which I assume to be the case since you're asking here rather than just emulating that), then don't do it. Conversely, if you do find examples of it being done, copy that method.

• Thank you for your answer (at least you made an attempt - which others haven't) but you're making an assumption about what is necessary based on a simplistic example I've given you, which is not as complex as the actual output. I cannot find similar use-cases in the literature, which is why I've come here. Also as mentioned these are pseudocode-ish equations, not pseudocode. So probably my question is better phrased as 'how to format equation steps with actual variable values' or something along those lines. Will update. Commented Jan 9, 2017 at 21:46

You're talking about display formulas (`\[...\]` in LaTeX), not about inlined formulas (`\$...\$`), right? In this case, I would use a two column table with a vertical line between the columns, i.e.,

``````  i = i + 1;   |  i = 2;
j = k;       |  j = 3;
k = k + i;   |  k = 5;
``````

That looks cleaner to me than putting the second formula in parentheses.

• Thanks for that - doesn't answer the question of whether there's a standard way to do this, but it's a useful suggestion, so upvoted :) Commented Jan 11, 2017 at 0:50