\block 内的逐字

\block 内的逐字

我已经寻找解决方案但没有找到适合我的。

我的目标是在块环境中编写一些命令。即使我用过\cprotect\protect它仍然不起作用。通常我使用\verb+Command+它。你们知道如何解决这个问题吗?

这是一张海报,因此,它使用 beamer。[编辑] 代码中的第二部分是模板中的设计部分

\documentclass[20pt,margin=1in,innermargin=-4.5in,blockverticalspace=-0.25in]{tikzposter}
\geometry{paperwidth=42in,paperheight=30in}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{enumitem}
\usepackage[backend=biber,style=numeric]{biblatex}
\usepackage{emory-theme}
\usepackage{pstricks}
\usepackage{xcolor}
\usepackage{pst-plot}
\usepackage{pst-circ}
\usepackage{threeparttable}
\usepackage{listings}
\usepackage{verbatim}
\usepackage{cprotect}
\usepackage{fancyvrb}


\usepackage{mwe} % for placeholder images

\addbibresource{refs.bib}

\tikzposterlatexaffectionproofoff
\usetheme{EmoryTheme}
\usecolorstyle{EmoryStyle}

\begin{document}
\maketitle
\centering
\begin{columns}
    \column{0.32}
    \block{lalala}{  

    }
    \column{0.36}
    \block{info}{
    }
    \block{basics}{
        texttexttexttexttexttexttexttexttexttexttexttexttexttext:\\
        \cprotect\verb+\usepackage{}+
    }
    \column{0.32}
    \block{something}{  
    }
\end{columns}
\end{document}     

名称:emory-theme.sty

% Emory Theme for the tikzposter % package. % % Author: Blair J. Rossetti % Last Modified: 2018-11-15 % % -- COLORS -- % emory primary palette \definecolor{EmoryBlue}{HTML}{002878} % Pantone 280(primary) \definecolor{MediumBlue}{HTML}{0033a0} % Pantone 286 \definecolor{LightBlue}{HTML}{007dba} % Pantone 7461 \definecolor{Yellow}{HTML}{f2a900} % Pantone 130 \definecolor{Gold}{HTML}{b58500} % Pantone 125 \definecolor{MetallicGold}{HTML}{8d702a} % Pantone 8640 % emory secondary palette \definecolor{Cyan}{HTML}{00aeef} % Pantone Cyan \definecolor{SkyBlue}{HTML}{41b6e6} % Pantone 298 \definecolor{Teal}{HTML}{487f84} % Pantone 5483 \definecolor{KellyGreen}{HTML}{348338} % Pantone 7740 \definecolor{SeaGreen}{HTML}{006c5b} % Pantone 568 \definecolor{Olive}{HTML}{5c8118} % Pantone 370 \definecolor{Orange}{HTML}{c35413} % Pantone 1595 \definecolor{Red}{HTML}{da291c} % Pantone 485 \definecolor{Magenta}{HTML}{c6007e} % Pantone 233 \definecolor{Purple}{HTML}{6558b1} % Pantone 2102 \definecolor{Grape}{HTML}{6d2077} % Pantone 259 % emory neutrals palette \definecolor{Black}{HTML}{101820} % Pantone Black 6 \definecolor{CoolGray5}{HTML}{b1b3b3} % Pantone Cool Gray 5 \definecolor{CoolGray2}{HTML}{d0d0ce} % Pantone Cool Gray 2 \definecolor{CoolGray1}{HTML}{d9d9d9} % Pantone Cool Gray 1 % emory web palette \definecolor{LightYellow}{HTML}{ffde75} % tikzposter color palette \definecolorpalette{EmoryPalette} {
    \definecolor{colorOne}{named}{LightBlue}
    \definecolor{colorTwo}{named}{LightYellow}
    \definecolor{colorThree}{named}{Gold} } % tikzposter style \definecolorstyle{EmoryStyle} {
    \usecolorpalette{EmoryPalette} }{
    % background
    \colorlet{backgroundcolor}{white}
    \colorlet{framecolor}{white}
    % title colors
    \colorlet{titlefgcolor}{Black}
    \colorlet{titlebgcolor}{white}
    % block colors
    \colorlet{blocktitlebgcolor}{colorOne}
    \colorlet{blocktitlefgcolor}{white}
    \colorlet{blockbodybgcolor}{white}
    \colorlet{blockbodyfgcolor}{Black}
    % innerblock colors
    \colorlet{innerblocktitlebgcolor}{white}
    \colorlet{innerblocktitlefgcolor}{Black}
    \colorlet{innerblockbodybgcolor}{colorTwo}
    \colorlet{innerblockbodyfgcolor}{Black}
    % note colors
    \colorlet{notefgcolor}{Black}
    \colorlet{notebgcolor}{colorTwo}
    \colorlet{noteframecolor}{colorTwo} } % -- STYLE -- % background \definebackgroundstyle{EmoryBackgroundStyle}{
    \draw[line width=0pt, color=framecolor, fill=backgroundcolor]
    (bottomleft) rectangle (topright); } % title \definetitlestyle{EmoryTitleStyle}{
    width=\textwidth, linewidth=5pt, titletotopverticalspace=0in }{
    \begin{scope}[line width=\titlelinewidth,]
    \draw[color=colorThree!30!white,round cap-round cap]
    (\titleposleft,\titleposbottom)--(\titleposright,\titleposbottom);
    \end{scope} } % block \defineblockstyle{EmoryBlockStyle}{
    titlewidthscale=0.95, bodywidthscale=1, roundedcorners=5 }{
    \draw[color=framecolor, fill=blockbodybgcolor,
    rounded corners=\blockroundedcorners] (blockbody.south west)
    rectangle (blockbody.north east);
    \ifBlockHasTitle
    \draw[color=framecolor, fill=blocktitlebgcolor,
    rounded corners=\blockroundedcorners] (blocktitle.south west)
    rectangle (blocktitle.north east);
    \fi } % -- THEME --  % emory theme \definelayouttheme{EmoryTheme}{
    \usecolorstyle[colorPalette=EmoryPalette]{EmoryStyle}
    \usebackgroundstyle{EmoryBackgroundStyle}
    \usetitlestyle{EmoryTitleStyle}
    \useblockstyle{EmoryBlockStyle}
    \useinnerblockstyle{Default}
    \usenotestyle{Default} } % -- TITLE FORMAT -- % place logo to right of centered title \makeatletter \renewcommand\TP@maketitle{%    \centering    \begin{minipage}[b]{0.8\linewidth}
        \centering
        \color{titlefgcolor}
        {\bfseries \Huge \sc \@title \par}
        \vspace*{1em}
        {\huge \@author \par}
        \vspace*{1em}
        {\LARGE \@institute}
    \end{minipage}%
    \tikz[remember picture,overlay]\node[anchor=south east,xshift=0.5\linewidth,inner sep=0pt] {%
       \@titlegraphic
    }; } \makeatother

答案1

逐字文本不能用作另一个命令的参数。有几种方法可以解决这个问题。一种方法是直接使用\texttt{}。这不太方便,但比完全不能使用它要方便。另一种方法是fancyvrb预先保存逐字文本,然后在命令中使用保存的文本。我已将您的示例精简为更简洁的内容以显示两种可能性:

\documentclass[20pt,margin=1in,innermargin=-4.5in,blockverticalspace=-0.25in]{tikzposter}
\geometry{paperwidth=42in,paperheight=30in}
\usepackage[utf8]{inputenc}
\usepackage{fancyvrb}
\DefineShortVerb{\|}
\SaveVerb{verb}|\usepackage{}|


\tikzposterlatexaffectionproofoff


\begin{document}
\maketitle
\centering
\begin{columns}
    \column{0.32}
    \block{lalala}{  

    }
    \column{0.36}
    \block{info}{
    }
    \block{basics}{
        texttexttexttexttexttexttexttexttexttexttexttexttexttext:

        \texttt{\textbackslash usepackage\{\}}
        \UseVerb{verb}
    }
    \column{0.32}
    \block{something}{  
    }
\end{columns}
\end{document}   

部分代码的输出

答案2

我的软件包的最新版本fvextra扩展了fancyvrb,它提供了一个\Verb命令,只要您不需要#%或不成对的花括号,该命令通常可以在其他命令中正常工作。如果您确实需要这些或有其他特殊要求,fvextra还提供了\EscVerb,其中任何特殊字符(如#%或不成对的括号)都可以通过用反斜杠转义来包含。

\documentclass[20pt,margin=1in,innermargin=-4.5in,blockverticalspace=-0.25in]{tikzposter}
\geometry{paperwidth=42in,paperheight=30in}
\usepackage[utf8]{inputenc}
\usepackage{fvextra}

\tikzposterlatexaffectionproofoff

\begin{document}
\begin{columns}
    \column{0.36}
    \block{block title}{
        text that goes on for a while

        \Verb{\usepackage{}}

        \EscVerb{\\usepackage{}}
    }
\end{columns}
\end{document} 

相关内容