CHICAGO — Cabrini-Green, the Robert Taylor Homes: demolished years ago, Chicago’s most notorious projects continue to haunt the city, conjuring up the troubled legacy of postwar public housing in America.

By the 1970s, Washington wanted out of the public housing business, politicians blaming the system’s ills on poor residents and tower-in-the-park-style architecture, channeling tax breaks toward white flight and suburban sprawl. Now the nation’s richest cities invent all sorts of new ways not to solve the affordable housing crisis.

Is any city doing public housing right these days?

I recently visited three sites that the Chicago Housing Authority has just or nearly completed. These small, community-enhancing, public-private ventures, built swiftly and well, are the opposite of Cabrini-Green and Robert Taylor. With a few dozen apartments each, they’re costlier per unit than the typical public housing developments, and they’re not going to make a big dent in a city with a dwindling population but a growing gap between the number of affordable apartments and the demand for them.

That said, they’re instructive. As Cabrini-Green and other isolated, troubled old mega-sites proved, bigger isn’t necessarily better. These are integrated works of bespoke architecture, their exceptional design central to their social and civic agenda.

And they share another distinctive feature, too: each project includes a new branch library (“co-location” is the term of art). The libraries are devised as outward-facing hubs for the surrounding neighborhoods, already attracting a mix of toddlers, retirees, after-school teens, job-seekers, not to mention the traditional readers, nappers and borrowers of DVDs.

Co-location is of course not a new idea. Other cities today link subsidized housing developments with libraries, New York included, but Chicago’s outgoing mayor, Rahm Emanuel, has made a point of touting the concept, and seeing it through in ways other mayors haven’t.

He leaves office next week with his reputation still tainted by the uproar several years ago following the release of the video of the police shooting of Laquan McDonald. The city’s downtown glistens but poorer residents south and west of downtown struggle with shuttered schools and unending gang violence.

These three new housing projects, on the city’s north and west sides, are clearly part of what Mr. Emanuel hopes will be his ultimate legacy. The projects mix public housing units with heavily-subsidized apartments and, in one case, market-rate ones.

Mr. Emanuel talked often as mayor about the value of public space and good design. People don’t only need affordable apartments, as he has said. Healthy neighborhoods are not simply collections of houses. They also require things like decent transit, parks, stores, playgrounds and libraries.

Mr. Emanuel extended the city’s subway system, network of bike lanes and popular Riverwalk. He completed the elevated, long-discussed 606, Chicago’s version of New York’s High Line; brought marquee stores like Whole Foods and Mariano’s to grocery-starved neighborhoods like Englewood, and parks like La Villita, replacing a former Superfund site, to communities like Little Village.

He also commissioned leading local architects to design a string of small, civic gems, including two boathouses by Studio Gang and a new branch library in Chinatown by Brian Lee, from the Chicago office of Skidmore, Owings & Merrill, which I have stopped into on a couple of occasions. It’s a neighborhood linchpin and landmark.

Mr. Emanuel’s predecessor, Richard M. Daley, who tore down what remained of Cabrini and began to replace old, debased developments with New Urbanist-style mixed-income ones, gave Chicago Millennium Park and loads of planted flowers. He built cookie-cutter library branches, police and fire stations. I toured the Edgewater library one morning, a two-story, brick-and-concrete box, about as inviting from the outside as a motor vehicle bureau office and ostensibly indistinguishable from one.

The cookie-cutter model was conceived to lower building costs and insure a kind of architectural equivalence across diverse neighborhoods. Library officials tell me the one-size-fits-all design invariably needed some tweaking, from site to site, so it didn’t turn out to be especially economical. And the common denominator obviously did nothing to beautify Chicago or celebrate communities with distinct personalities and desires.

Mr. Emanuel adopted a different model. Capitalizing on the city’s architectural heritage, he touted striking new civic architecture as an advertisement for the city and a source of community pride. Distinguished civic buildings in underserved neighborhoods constituted their own brand of equity. Good architecture costs more but it pays a dividend over time.

The three new housing projects partner the Chicago Housing Authority with the Chicago Public Library system and two private developers, Evergreen Real Estate Group and Related Companies. Working with Eugene E. Jones, Jr., who runs the Housing Authority, Mr. Emanuel persuaded federal officials that public libraries could be co-located with public housing projects without putting federal housing subsidies at risk.

That freed up streams of money for the co-location idea, which was partly strategic: the library helped sway community groups resistant to public housing in their neighborhoods.

But co-location was also just plain good urban planning. In cities across the country, branch libraries, which futurologists not long ago predicted would be made obsolete by technology, have instead morphed into indispensable and bustling neighborhood centers and cultural incubators, offering music lessons, employment advice, citizenship training, entrepreneurship classes and English-as-a-second-language instruction. They are places with computers and free broadband access. (One in three Chicagoans lacks ready access to high-speed internet.)

For longtime neighborhood residents and tenants of the new housing projects, the branches at the same time provide common ground in a city siloed by race and class.

A city-run architecture competition in 2016 attracted submissions from 32 local firms. The winners were John Ronan, the architect who did the beautiful Poetry Foundation headquarters in downtown Chicago; Mr. Lee from Skidmore; and Ralph Johnson, who also designed the O’Hare international terminal, from the local office of Perkins + Will.

The libraries share real estate with the apartments but maintain separate entrances. The apartment blocks are designed to command views from a distance; the glassed-in libraries, to command the street.

Mr. Johnson’s project, the $34 million Northtown Affordable Apartments and Public Library, near Warren Park, is a four-story snaking structure, shaped like a twisty garden hose, trimmed in fluorescent green, backing onto a historic bungalow district, along a stretch of avenue that features a Jiffy Lube and Mobil station. It’s meant to be, and is, a beacon and an eye-catcher.

The building’s upper floors include 44 one-bedroom apartments for seniors. They perch atop a bright, glazed, double-height, 16,000 square foot library, which curves around an interior, teardrop-shaped garden, the library’s roof doubling as a terrace for the housing tenants. The apartments I saw looked great, with floor-to-ceiling windows. A community garden in the back helps negotiate the tricky transition between the bungalows and the busy avenue.

Mr. Ronan’s Independence Library and Apartments, in Chicago’s Irving Park neighborhood, a $33.4 million project, tells a similar story. Evergreen is again the developer. The apartments, one- and two-bedrooms, as at Northtown, are all subsidized for 44 seniors and the library occupies the ground floor. The six-story apartment block is a vivid, snowy white tower with rounded corners, clad in corrugated metal, punctuated by multicolored balconies.

The library juts toward the street. It’s a soaring, two-level affair, with a music studio and makers’ workshop tucked into a corner, towering concrete columns, bleacher seats and a mezzanine facing a big, teak-lined roof deck that is accessible from the apartments. The place is welcoming and richly detailed. Light pours in from three directions. Patterned wallpapers, among other touches of color, soften a vocabulary of exposed and striated concrete, with the corrugated metal on the outside serving as radiant paneling for distributing heat inside.

Mr. Lee’s project, the Taylor Street Apartments and Little Italy Branch Library, encountered the fiercest community resistance. The blowback ended up reducing the size of the apartment tower and stepping its mass back from the street.

The $41 million project includes 73 apartments, seven of them market-rate. Related is the developer. At seven stories, clad in Aztec-brick and chestnut-colored panels, the building at once stands out from but also echoes aspects of the neighborhood. There are two floors with glassed-in, single-loaded corridors, the sort of perk you mostly find in high-end residential developments. A double-height library, with a curtain wall and bright orange acoustic baffles, anchors the street.

When I stopped by, moms clustered with toddlers in a bright corner of the library. The place was quiet, dignified and cheerful. Upstairs, views onto empty lots suggested more development coming. The area is gentrifying.

Like the other two, the project seemed both bulwark and boon. This may not be the only way to solve America’s affordable housing problem, but it’s a start.