Along with the diplomats, security police and journalists in the Panamanian entourage here for the signing of the canal treaties, Gen. Omar Torrijos brought along a formidable literary arsenal: Gabriel Garcia Marquez, Latin America's foremost living novelist, and Briton Graham Greene.

Garcia Marquez, 49, a Columbian best known here for "One Hundred Years of Solitude," is on the left of the Latin literary world and has produced some journalistic efforts himself recently on Cuba and Angola. He said yesterday that he has spent much time recently in Panama, 'at first with the idea of doing a journalistic piece. But now I know too many things that I am not permitted to write. I'll have to save them for my memoirs."

Although much of the Latin-left is uncomfortable with Torrijos, Garcia Marquez called him "an excellent person . . . who has helped me overcome my prejudice against the military."

The salty author not only accepted Torrijos' invitation but took advantage of the visit here to accept another: to read from his works for the recorded history program of the Library of Congress.

Garcia Marquez asked, however, not to be included in the Panamanian delegation to last night's White House or State Department dinners - he chose instead to attend a protest march against the presence of Chile's military ruler, President Augusto Pinochet.

Whereas other Latin leftists have denouced President Carter for inviting Pinochet, Garcia Marquez was sympathetic. "It seems to me the invitation was an insult, but I understand that he had no alternative."

He added: "I believe in the good faith of President Carter" in seeking to convince the Senate - through the gathering of the Latin leaders - that the hemisphere is united behind Torrijos. But he warned that Carter "is playing a difficult card . . . If he doesn't get [Senate] ratification he has no other card to play."

If the treaties are not ratified now, after 13 years of Panamanian effort in negotiation, he said, "they will have to turn to the other road" of force. For the panamanians' part, he prediced that 90 percent would vote in favor of ratification in the plebiscite there.

Garcia Marquez foresees the possibility of violence even if the Senate ratification vote is put off. "The danger is that for many Latin Americans this is more attractive than negotiations - more romantic." And besides, he said, the date for turnover of the canal zone by phalanxes of unarmed off." He pictured an invasion of the canal zone by phalanxes unarmed writers and poets, and asked rhetorically if the United States could then defend the land with guns.

"I personally think the Senate will ratify," he concluded, "but it will be the death of all President Carter's efforts on Latin America if it does not."

Garcia Marquez then hurried off to the Library of Congress. He showed only the slightest irritation that in agreeing to read there he was following in the footsteps of Argentina's conservative literary great, Jorge Luis Borges.

Borges is given to short stories rather than novels and is also given to scathing criticism of leftist political positions. He was at the library last year. "Each time I hear him say these things I declare I will never read him," said Garcia Marquez. "But when another book appears, I cannot put it down."

For his part, Garcia Marquez chose to read atthe library from his most recent, "and most difficult" novel," "The Autumn of the Patriarch," published in English last year.

obviously at ease in the United States, although reluctant to speak any English, Garcia Marquez is enrolling one of his two sons at Harvard this fall.

A note in The Washington Post last January accompanying an article by Garcia Marquez identified him as a Communist. He said yesterday that "I do not belong to any party, but I do believe that Latin America will be Socialist and I want it to be. I believe, further, that the most splendid Socialist revolution will be in the United States." He thought half a second and added: "Probably it will be the last one."

His next work, he said, will be on Cuba, where he has spend considerable time interviewing Fidel Castro and getting to know the island "so similar to where I was born" - on the Caribbean coast of Columbia.

Alluding to Castro's support in the past for Torrijos's canal negotiations, Garcia Marquez said "It does not surprise me that Cuba has not said a single word" at this critical time on the question of the signing by Carter and the panamanian.

Graham Greene, 72, has said he was visiting Panama - one of the few places he has been, he said, to which he can return - when Torrijos invited him to come along. He disavowed any intention to write anything about the canal ceremonies any time soon, "perhaps in five years."

The author, whose novels have so often punctured the military pretensions of Latin dictatorships, arrived, as did Garcia Marquez, on an official Panamanian passport. At an Organization of American States cocktail party he tried to get close enough to Pinochet to be able to refuse to shake hands, but he was outmaneuvered on a crowded floor.