Fixed bugs introduced by merging PR #2732.

Printing of vectors and dyadics was broken when PR #2732 was merged due to
some missing imports. There were no tests for this, so I've added a couple for
pretty printing. I have some tests for latex printing in PR #2772 that has not
been merged yet.

PR #2732 also reverted the changes in PR #2728 by accident. This introduces those changes back into the code base.