After nearly a year of searching, the Smithsonian Institution has picked Alan Fern of the Library of Congress as the new director of the National Portrait Gallery.

As the library's director for special collections, Fern, 51, has been the man in charge of its enormous holdings of manuscripts, maps, films and sound recordings, photographs and prints. Few officials there are as well known in this city.

"I have consciously kept my visibility in the world of art," says Fern, who regularly appears at openings and lectures and art exhibitions. "I wanted to remind my colleagues that I was still an art historian--not just a faceless bureaucrat in the Library of Congress." In 20 years with the library, Fern has earned a reputation as a skillful administrator, a specialist in prints, and a subtle art world diplomat. He will join the Portrait Gallery June 1.

The gallery has been without a director since Marvin Sadik, a highly regarded museum professional who had tired of the job, resigned suddenly last spring. Sadik is now a private art dealer in Maine.

In this city of museums, the National Portrait Gallery, which opened to the public in 1968, seems somehow set apart by its slightly awkward mission. Though it often displays art, it is not an art museum. Nor, though all the subjects of the likenesses that it collects must be dead at least 10 years, is history its only field. Perhaps, with its varied exhibitions including memorabilia and documents, it may be best described as a national museum of American individuals.

Although few Americans in our age sit for sculpted or painted portraits, the gallery's acquisitions were once limited, by law, to paintings, drawings, prints and statues. One rationale was that the gallery would otherwise compete for films and photographs with the Library of Congress. That restriction was removed in 1976. Thougn Fern was then in charge of the library's collections, he thought the limitation "silly," and lobbied for the change.

The Portrait Gallery, which has an annual budget of about $3 million, owns some 2,000 portraits. Fern, at the library, is in charge of many millions of objects--cartoons, prints, the Farm Security Administration's Depression-era photographs, posters and the like. His knowledge of these objects, many of which may be loaned to the museum, is expected to prove useful. "One of the things I bring to the job is an intensive knowledge of other collections--collections that can be shared," he said.

Fern, born in Detroit, was trained at the University of Chicago. He received his bachelor's degree in 1950, his master's in 1954, and his doctorate in art history in 1960.

Joshua C. Taylor, the late director of the National Collection of Fine Arts (now the National Museum of American Art), who died here last April 26, was, at first, Fern's thesis supervisor, then his fellow teacher in Chicago. The Portrait Gallery and the Museum of American Art share the Old Patent Office Building, a Greek Revival monument between 7th and 8th and F and G streets NW. Though Taylor and Sadik often sniped at one another (they both seemed to enjoy it), the relationship between the neighboring museums is expected to improve.

Fern and Charles C. Eldredge, who will become director of the National Museum of American Art on July 1, describe themselves as admirers of Joshua Taylor.

Charles Parkhurst, assistant director of the National Gallery of Art, described Fern's appointment as "very ingenious. He is not the person I'd have picked right off the bat, but I'd have kicked myself for not thinking of him. Everybody likes him, everybody knows him, he really gets around. He is a consummate art diplomat."

Fern, who has written on a variety of subjects, including Art Nouveau, revolutionary Soviet film posters, and the prints of Leonard Baskin, is a former president of the Print Council of America. He was art history chairman of the 1979 meeting of the College Art Association, and now serves on the boards of the Swann Foundation (of caricatures and cartoons) and the Paul Strand Foundation. (Strand was the great photographer whose negatives are now in the Library of Congress.) During the 1960s, when commercial galleries in Washington were trying to build a market for photographs, Fern, an amiable, pipe-smoking man and an amateur photographer, encouraged many dealers here. One of them, Harry Lunn, called his appointment "superb . . . and safe."