They huddled in the cold on a graffiti-covered bench last November, the twin girls dozing in their parents’ laps while the older children buried their heads in their phones.

Most nights, the family of six waited like this outside a San Francisco school gymnasium until it could be converted into a homeless shelter. Once inside, they slept each night on a small patch of the floor, then rose early each morning to secure a spot in one of the three showers shared by 69 people. They had to leave by sunrise so the school gym could be returned to its intended purpose.

Margarita Solito, 36, sometimes wondered if the 3,200-mile journey to San Francisco from El Salvador had been worth it. The family left as international migrants, and now they were migrants of a different sort, moving around their new city all day with nowhere to call home.

A year after arriving in the city, Ms. Solito’s fight for housing would pay off, and her family would be able to put down roots. But their journey shed light on the larger crisis of family homelessness in San Francisco and revealed the daily uncertainty that hundreds of schoolchildren face there.