When installing CWR (continuous welded rail) it is anchored every other tie at a pre-determined "neutral" rail temperature, which depends on where you are located, with it being different in the SW as opposed to North Dakota for instance. In WV we generally used (as near as I can remember) 95 degrees. In reality we tried to anchor it when it was as hot as possible- if we had the luxury we normally laid CWR in the summer when it was easy to get it hot. As noted above, sometimes you get a "pullapart" in cold weather. Then you either use a hydraulic rail stretcher to bring it back together or you heat it with a rope soaked in diesel or sawdust soaked in diesel and set on fire. Dirty messy work. Or else you cut in a short "dutchman" and hope nobody catches it. .
When coming off of a grade crossing or turnout, where you absolutely don't want the rail to creep, it is box anchored (anchors every tie) for around 250 feet in each direction. That's generally pretty effective for keeping CWR in place.
I once ran a 90-car unit coal train over a track buckle w/o a derailment, I lost a lot of weight in sweat on a cold day. Another day we put 8 loaded new aluminum cars over the side of a hill due to a buckle. Cars alone cost our insurance (-our significant deductible) $60,000 apiece. Puts a serious bind on your profit margin.
Ned