While i don't have solved this problem (i can't find a way to retrieve canonical urls inside the code for categories without having to query the database) i have found a workaround for the moment that can answer at the same time this question "How can i add robots metatag to all the pages but questions and user profiles?"
You can override inside qa-theme.php the head_links function with this one:
function head_links(){
if($this->template !== 'question' && $this->template !== 'user'){
if(($_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']) != substr(qa_opt('site_url'), strpos(qa_opt('site_url'), '://') + 3)){
$this->output('<meta name="ROBOTS" content="noindex, follow"/>');
}
}
}
This function add the "noindex, follow" parameters to all pages but question and user profiles (those that are content pages basicaly) allowing Google to not index "archive" pages (that are often considered low value content) while still processing the link juice passed by these pages to question and user profile pages.
The noindex pages will not be included in the search engine index and they will not trigger any duplicate content filter.
NOTE: the code is experimental and has not been tested exstensively; use it at YOUR OWN RISK