我已經尋找了解決方案,但沒有找到適合我的解決方案。
我的目標是在區塊環境中編寫一些命令。雖然我用過\cprotect
還是\protect
不行。通常我用\verb+Command+
這個。你們知道如何解決這個問題嗎?
它是用於海報的,因此使用了投影機。 [編輯]程式碼中的第二部分是模板的設計部分
\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
extends fancyvrb
,提供了一個\Verb
命令,只要您不需要#
或%
不成對的大括號,該命令通常可以在其他命令中正常工作。如果您確實需要這些或有其他特殊要求,fvextra
還提供\EscVerb
,其中透過使用反斜線轉義來包含任何特殊字符,例如#
or或不成對的大括號。%
\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}