I think the following should work:
let pp_x (chan: out_channel) (b: bool) (x: x) =
let fmt0 = format_of_string "(%a, %a)" in
let fmt1 = format_of_string "%a%a" in
let e0, e1 = ... in
Printf.fprintf chan (tern b fmt0 fmt1) pp_e e0 ppe e1
I've tested the basic idea and it worked for me. I can't test with your code because of the many parts that are missing.