Rebus was turned down five times, says Ian Rankin
Author Ian Rankin says his favourite item in an exhibition celebrating 30 years of his most famous character is a letter from his agent "naming and shaming" the five publishers who turned down his first novel featuring Inspector John Rebus.
Knots and Crosses was eventually published by Bodley Head in 1987 and the no-nonsense cop went on to become one of the most popular characters in crime fiction, featuring in 21 novels.
Rankin's creation is now being celebrated in Rebusfest, a weekend of events including an exhibition at the Writer's Room in Edinburgh.
As well as the agent's letter, the exhibition also features the original manuscript for Knots and Crosses, which was typed in his Edinburgh student flat when he was a 24-year-old PhD student.
Rankin told BBC Scotland the plot came before the character of Rebus.
He had the idea for a novel in which someone was being sent picture puzzles but the character's memory had blocked out what they were supposed to mean.
"I wrote in my notes 'the main character may be a cop'," Rankin says.
"He pretty much sprung from that. I gave him the name Rebus because it means picture puzzle and he is being sent picture puzzles.
"I thought that was a clever thing to do.
"It's not really a Scottish name. I found out later it is a Polish name. He's got Polish roots. I didn't find that out until book 15."
Rankin says he never set out to be a crime writer.
"I didn't read much crime fiction, I just got the idea for a story when I was 24 years old and I had to write the story.
"I had an agent and she sent the book to six, mainly London, publishers and five immediately turned it down.
"In the letter I have got here at the exhibition she is waiting to hear from the sixth and thank goodness they took it.
"If they hadn't then Knots and Crosses would have gone into the bottom drawer and stayed there and Rebus would have gone in to the bottom drawer as well."
Rebus was not only fortunate to make it into print but he was also lucky to survive the first novel.
Rankin originally killed him off.
"At the end of the first book, because I thought I was only going to write one book about this guy, in the first draft he was shot and killed.
"Spoiler alert - for whatever reason I brought him back. I thought I'll injure but I won't kill him."
Rankin says he can't find the original ending of Knots and Crosses, he thinks it might have been eaten by mice when he stored all his records in his attic.
After the first Rebus novel, Rankin wrote a spy novel and a thriller.
He only came back to the curmudgeonly detective after his editor said there was more that could be done with him.
Rankin says: "I thought 'yes I want to explore Edinburgh in more depth and I want to use Edinburgh as a way of exploring Scotland'. A detective is a pretty good way of exploring society from top to bottom so he came back and he stayed."
The Rebusfest weekend will include all his favourite things - music, pubs and walking around Edinburgh. There will be a pub quiz and walking tours as well as discussion about the creation of the character.
Rankin, who has just got back from book tours in the US, Germany, Australia and New Zealand, says wherever he goes people are interested in coming to the festival and seeing Rebus' Edinburgh.
He says: "When Knots and Crosses was first published 30 years ago one of the first reviews said 'it is unlikely to be recommended by the Scottish tourist board'.
"We have gone from that to there being an official Rebus walking tour and people coming to Edinburgh looking for his city.
"We have come to realise now that tourists don't just come to Scotland looking for the traditional older cultural elements, they are looking to see what is the country now?
"The Rebus books have always been about contemporary Scotland, reflecting back on the past but also looking at the country it could become."
Rankin says his famous detective would not have enjoyed a celebration of his life but the writer says it has been interesting to look back on the changes over the past 30 years.
He says: "The extraordinary thing about looking back at that first novel is that it seems like an historical document, nobody has computers.
"If Rebus wants to make a phone call he stops the car and finds a phone box that has not been vandalised.
"The fax machine is a wee god that sits in the corner of then office and if a fax comes chugging out you immediately go over because it must be important."
He says the whole structure of the way police investigate crimes has changed, especially since the progress of DNA evidence.
"The only thing that has not changed is Rebus," Rankin says.