def latexsnippet(code, kvs, staffsize=17, initiallines=1):
    """Take in account key/values"""
    snippet = ''
    staffsize = int(kvs['staffsize']) if 'staffsize' in kvs else staffsize
    initiallines = int(kvs['initiallines']
        ) if 'initiallines' in kvs else initiallines
    annotationsize = 0.5 * staffsize
    if 'mode' in kvs:
        snippet = '\\greannotation{{\\fontsize{%s}{%s}\\selectfont{}%s}}\n' % (
            annotationsize, annotationsize, kvs['mode']) + snippet
    if 'annotation' in kvs:
        snippet = (
            """\\grechangedim{annotationseparation}{%s mm}{fixed}
\\greannotation{{\\fontsize{%s}{%s}\\selectfont{}%s}}
"""
             % (staffsize / 60, annotationsize, annotationsize, kvs[
            'annotation']) + snippet)
    snippet = ('\\gresetinitiallines{%s}\n' % initiallines + 
        '\\grechangestaffsize{%s}\n' % staffsize + 
        '\\grechangestyle{initial}{\\fontsize{%s}{%s}\\selectfont{}}' % (
        2.5 * staffsize, 2.5 * staffsize) + snippet)
    snippet = '\\setlength{\\parskip}{0pt}\n' + snippet + code
    return snippet
