@EricGT copied this and changed the owner to @CapelliC (ref)
To pad and align you should use tab stops, controlled by pairs of t
and |
. For instance, to print a table of numbers in spreadsheet default style (text left align, number right align):
test(indent) :- nl,
forall(member(L, [[a, 3.66, 55.5334],
[basd, 22.876345, 2113.4465],
[cas, 0.6623233, 53.5]
]),
format('~s~t~20|~t~3f~40|~t~3f~60|~n', L)).
Note the position of ‘space allocator’ specifier ~t , the absolute ‘column width’ ~| , regards the field type specifier. The output:
?- run_tests(sheet_inventory:indent).
% PL-Unit: sheet_inventory:indent
a 3,660 55,533
basd 22,876 2113,447
cas 0,662 53,500