tcolorbox: como fazer uma variante do mylib
Aug 16 2020
Essa questão :
Como reproduzir esta caixa em tcolorbox
tem uma resposta clara. Eu queria fazer uma variante semelhante com duas pequenas mudanças:
-em vez de LIB, use REMARKS (ok, isso é trivial)
-formatar o texto em marcadores (itemizar o ambiente)
\newtcbox{\myremarks}{enhanced,nobeforeafter,tcbox raise base,boxrule=0.4pt,top=0mm,bottom=0mm,
right=0mm,left=4mm,arc=1pt,boxsep=2pt,before upper={\vphantom{dlg}},
colframe=green!50!black,coltext=green!25!black,colback=green!10!white,
overlay={\begin{tcbclipinterior}\fill[green!75!blue!50!white] (frame.south west)
rectangle node[text=white,font=\sffamily\bfseries\tiny,rotate=90] {REMARKS} ([xshift=4mm]frame.north west);\end{tcbclipinterior}}}
\NewDocumentCommand\remarks{m}
{\myremarks{\begin{itemize} #1\end{itemize}}}
falhará nisso:
\remarks
{
\item Perfect relationships of $r=\pm1$ do not exist in the real world.
\item Correlation does not imply causation
}
falha ao notar um item ausente, então há algum tipo de problema de análise acontecendo.
É provável que a maneira ideal de fazer isso seja modificar o newtcbox diretamente para que formate o texto no itemize, mas eu nem sei por onde começar.
Respostas
2 muzimuzhiZ Aug 17 2020 at 05:05
Experimente isto:
- A opção
varwidth upper=\linewidth
é usada (com ovarwidth
pacote carregado) para permitir\myremarks
a composição de seu argumento no modo de parágrafo, que é exigido peloitemize
ambiente. Isso é equivalente a\myremarks{\begin{varwidth}{\linewidth} ...\end{varwidth}}
. - Como o texto girado
REMARKS
é mais alto do que a altura mínima de\myremarks
, a opçãoheight from=1.2cm to \maxdimen
é usada para definir uma altura mínima. - As opções de nó
pos=1, anchor=south east
são adicionadas para anexar textoREMARKS
ao topo, em vez de centralizado verticalmente. enumitem
as opçõesnoitemsep, leftmargin=5mm
são para ajustar os espaços deitemize
.
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usepackage{enumitem}
\usepackage{varwidth}
\usepackage{xparse}
\newtcbox{\myremarks}{
enhanced,nobeforeafter,tcbox raise base,
boxrule=0.4pt,top=0mm,bottom=0mm,
right=0mm,left=4mm,arc=1pt,boxsep=2pt,
before upper={\vphantom{dlg}},
colframe=green!50!black,coltext=green!25!black,colback=green!10!white,
overlay={
\begin{tcbclipinterior}
\fill[green!75!blue!50!white]
(frame.south west) rectangle
node[text=white,font=\sffamily\bfseries\tiny,rotate=90, pos=1, anchor=south east] {REMARKS}
([xshift=4mm]frame.north west);
\end{tcbclipinterior}
},
% equivalent to surround the cmd arg in "varwidth" env
varwidth upper=\linewidth,
% set minimum height for complete output of rotated "REMARKS"
height from=1.2cm to \maxdimen,
}
\NewDocumentCommand\remarks{m}{%
\myremarks{%
\begin{itemize}[noitemsep, leftmargin=5mm]
#1%
\end{itemize}
}%
}
\begin{document}
\remarks{
\item abc
}
\remarks{
\item abc
\item def
\item ghi
}
\end{document}

O que significa um erro “Não é possível encontrar o símbolo” ou “Não é possível resolver o símbolo”?
Christopher Nolan uma vez se arrependeu de ter lido o 'roteiro de Pulp Fiction' de Quentin Tarantino