It entirely depends on the whole context of the drive, the weather, the road, other traffic, time of day, etc. And it always depends on “sufficient space”, whether I’m following or leading.
A few considerations:
Often in heavy traffic on a level surface with multiple lanes and in good weather, I like to find the “traffic shadow” in front of a big truck. Since it’s not accelerating as fast as most of the smaller vehicles there’s usually a “hollow” in front of the truck. I don’t want to camp there and slow the truck in any way, but that’s usually a calmer place than the traffic rushing by on both sides.
Going downhill in almost any traffic I prefer to be well behind the truck – or very well ahead. Since I don’t know the driver’s level of competence and attentiveness, I want lots of space if I’m ahead, and also a good deal if I’m trailing. On a multi-lane road I prefer “some other lane”.
In general I prefer to be ahead, because when I trail my vision is so restricted that I leave more and more space between us, and other drivers who don’t seem to care as much just fill that up – and I dislike that, too.
Going uphill on multi-lane roads I very much prefer to be ahead, and I’m usually passing. When one truck passes another at +5 mph or less I try not to be irked, since I would like to be travelling at +10 mph or more (in general, and “at least”, since trucks traveling uphill are already likely to be traveling at less than the speed limit).
And when I pass a truck – on either side – I try to do it quickly and won’t do it unless I can get ahead to where I’m visible again. I never spend time alongside trucks.