Loans and hardship withdrawals from a 401(k)

When a plan allows a loan or a hardship withdrawal, the limits, the repayment rules, and the tax cost of getting it wrong.