Best-selling crime writer Ian Rankin has donated his literary archive to the National Library of Scotland.

Often cited as the "godfather of tartan noir", Rankin's series of 23 novels featuring grizzled Edinburgh police detective John Rebus has been translated into 36 languages.

It was also adapted into an STV drama featuring top Scots actor Ken Stott in the lead role.

Totalling around 50 boxes of material, which in shelving terms is more than 21 feet, the archive includes typescripts of manuscripts with handwritten annotations and notes by the author.

Also included is correspondence with other literary figures such as JK Rowling, Iain Banks, Ruth Rendell, Val McDermid and Jilly Cooper, as well as figures from across the political and cultural spectrum.

Not surprisingly, police officers also feature regularly in correspondence.

National Librarian Dr John Scally hosted a special event featuring Rankin on Thursday morning.

He said: "Ian Rankin is a well-known face to us here at the National Library. We knew him when he was researching Muriel Spark as part of his PhD, and we knew him when he penned his first novels here in our very reading rooms.

"Little did we know then just how successful he was to become, and that in time, his archive would be as gratefully received as Spark's.

"It will be preserved into perpetuity alongside other Scottish literary giants.

"Rankin's main protagonist, John Rebus, has walked George IV Bridge many times, and frequently visited this very Library while researching cases.

"We are honoured to be a character in the Rebus novels alongside the city of Edinburgh, and we feel this is the rightful home for Ian's archive.

"Because of his generosity, readers will be able to gain insight into the creative process of this wonderful writer."

Described by Rankin as "a pretty complete author's life, late-20th century-style", the archive material dates from 1972-2018.

The author said: "I remember that in my first week as a postgraduate student we were given a tour of the National Library of Scotland, including access to the basement levels.

"Those vaulted underground corridors would reappear in the climactic scenes of my first Rebus novel.

"The library has seemed like a friend ever since, so it seems fitting - as well as a thrill and an honour - that my archive should find a permanent home there."

The National Library will recruit a curator to catalogue and promote the Ian Rankin archive.

Dr Scally added: "This is a comprehensive, fascinating, in-depth archive, spanning several decades. It is rich in detail - all of which will become fully apparent as the curator works through the archive.

"We must thank Ian for making a substantial donation towards the creation of this post. This means we will soon be able to open up the archive to all."

The curator post is also made possible through donations from The W M Mann Foundation and The Gladys Krieble Delmas Foundation.