# Inline colorbox & linebreaks

First and foremost, I have found some solutions here, here, and there but they seem overly complicated for what I am trying to accomplish.

## Problem

I am trying to somewhat reproduce the code environment "markdown-style" in LaTeX. I used a colorbox in conjunction with texttt to get a pretty satisfying look but it does not allow line breaks and thus breaks everything when used with paths or long lines.

## Question

It is my understanding that colorbox cannot be used to output multiple lines. What could help me achieve this while keeping the code fairly clean?

## MWE

\documentclass[draft]{article}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{geometry}
\usepackage{pdftexcmds}
\usepackage{xcolor}
\newcommand{\code}[1]{\colorbox{black!30}{\textcolor{black!90}{\texttt{\detokenize{#1}}}}}
\newcommand{\codeA}[1]{\colorbox{black!30}{\textcolor{black!90}{\texttt{#1}}}}
\begin{document}
test \code{code} test \code{+}

\lipsum[1]

\codeA{\lipsum[2]}
\end{document}

• Welcome to TeX.SX! Have you looked at listings or minted? Those are both packages for code highlighting and as far as I know they support background color as well as line breaking. I'd start with minted if you have no problem compiling with -shell-escape. :) – Guilherme Zanotelli Nov 22 '16 at 14:39
• @Guilherme Z. Santos I do use minted when I need to display code blocks indeed. What I am looking for here is a way to show inline code snippets. – Florian Nov 23 '16 at 10:32
• Both minted and listings offer macros to display inline code. Minted macro is: \mintinline{<language>}{code}. – Guilherme Zanotelli Nov 23 '16 at 10:34
• @Guilherme Z. Santos Thank you for the heads up. I think I will be working with this as for now. I will keep looking for a way to manage to do so without minted when I find some time. – Florian Nov 23 '16 at 11:11
• why would you want to do it without minted? If there's a specific reason you're looking to use the package less perhaps you should see the listings package, I think they are compatible . Not using listing packages at all will surely lead to an overcomplicated solution which you seem to want to avoid... – Guilherme Zanotelli Nov 23 '16 at 14:36