1

I use XeLaTeX, but I can not use both or similar or duplicate packages, because someone said it is bad idea in XeLaTeX. I would like to use only minted.

Here are two answers which offer inline code with rounded corners, but only for lstinline and minted:

But in these links, both they depend on listings.

Few codes taken from the one of two links and I readjusted few commands and words, as principally replacing listing. for minted and \lstinline. for \mintline, without depending on listings, but it does not work without listings. Here is the smaller code:

\documentclass[10pt, a4paper, portuguese]{abntex2}
\usepackage{etoolbox}
\usepackage{tcolorbox}
\tcbuselibrary{minted, skins, xparse}

\BeforeBeginEnvironment{minted}{\vspace{2mm}\begin{tcolorbox}[colback=bg, colframe=bg, arc=1.2pt]}%
\AfterEndEnvironment{minted}{\end{tcolorbox}\vspace{2mm}}%

\usepackage{newverbs}
\definecolor{inline}{RGB}{187,57,82}
\newverbcommand{\cverb}{\color{inline}}{}
\usemintedstyle{paraiso-dark}

\DeclareTotalTCBox{\commandbox}{ s v }
{minted, enhanced, frame hidden, arc=2pt}
{\IfBooleanTF{#1}{\textcolor{red}{\ttfamily\bfseries > }}{}%
\mintinline{#1}{#2}^#3^}

\begin{document} 

\commandbox{php}{<?php echo "Hello!" ?>}

\end{document}

And without depending on listings and with tikz from Making Inline Code Printing Pretty, I only replaced {\texttt{#2}} for {\mintinline{#1}{#2}}, but I tested and it did not work error:

\documentclass[10pt, a4paper, portuguese]{abntex2}

%...

\newcommand{\inlinecode}[2]
{
    \tikz[baseline=(s.base)]
    {
        \node(s)
        [
            rounded corners,
            fill = whitesmoke, % background color
            % draw = prussianblue,    % border of box
            text = solitudeblue,  % text color
            inner xsep = 2pt,    % horizontal space between text and border
            inner ysep = 0pt,    % vertical space between text and border
            text height = 2ex,    % height of box
            text depth = 1ex,    % depth of box
            #1                  % other options
        ]{\mintinline{#1}{#2}};
    }
}

\begin{document} 

The basic code in PHP \inlinecode{php}{<?php echo "Hello $name" ?>}

\end{document}
  • The code in the second link (tex.stackexchange.com/q/452150/35864) still works fine if all references to listings are removed. – moewe Nov 17 '18 at 12:11
  • 1
    BTW: It is always bad to load packages twice or to load packages you don't need or don't know what they are doing (not only with XeLaTeX). It is also always a good idea to try and reduce the number of packages loaded: minted and listings do very similar things, so it seems not too far-fetched that it should be possibly to use only one of the two. AFAIK minted and listings are not incompatible, so it is not bad to use both, but it is nicer to get away with using only one of the two. – moewe Nov 17 '18 at 12:22
  • 1
    Check what one package does. Check what the other package does. Check that against what you want to do. Tell us what you want to do so we don't just guess. Also make a MWE so we don't have to guess some more. – Joseph Nov 17 '18 at 15:01
  • 2
    @GustavoReis, it's not a MWE -- see tex.meta.stackexchange.com/questions/228/…. In the links you took that code from you have examples of MWE (which work). What do you want that is different from them? – Joseph Nov 18 '18 at 11:15
  • 1
    @GustavoReis It is still not a MWE. Have you looked the link provided by Joseph? A MWE should be a short compilable code that reproduces the issue, thus, starting with \documentclass{...} and ending with \end{document}. – gusbrs Nov 18 '18 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.