
Quiero hacer cajas de colores con diferentes colores y no puedo entender la función del orden mybox{}. Te adjunto un ejemplo que puede ayudarte.
escribo el codigo
\documentclass[a4paper]{report}
\usepackage[greek]{babel}
\usepackage[iso-8859-7]{inputenc}
\usepackage{xcolor}
\usepackage{blindtext}
\usepackage{tikz,tkz-tab,amsmath}
\begin{document}
\newcommand{\mybox}[1]{%
\begin{center}%
\begin{tikzpicture}%
\node[rectangle, draw=green, top color=green!10, bottom color=green!90, rounded corners=5pt, inner xsep=5pt, inner ysep=6pt, outer ysep=10pt]{
\begin{minipage}{1.05\linewidth}#1\end{minipage}};%
\end{tikzpicture}%
\end{center}%
}
\mybox{\textlatin{\blindtext}}
\end{document}
y el resultado es este:
Respuesta1
Puede agregar un parámetro \mybox
en el que pueda especificar un color alternativo. Entonces
\mybox{text}
producirá un cuadro que utiliza green
(el color predeterminado como se especifica en la mybox
definición), pero
\mybox[red]{text}
utilizará red
:
Sin embargo, le recomendaría que utiliceelmdframed
paqueteen cambio:
Código: tikz
nodo
\documentclass[a4paper]{report}
\usepackage[greek]{babel}
\usepackage{xcolor}
\usepackage{blindtext}
\usepackage{tikz}
\newcommand{\mybox}[2][green]{%
\begin{center}%
\begin{tikzpicture}%
\node[rectangle, draw=green, top color=#1!10, bottom color=#1!90, rounded corners=5pt, inner xsep=5pt, inner ysep=6pt, outer ysep=10pt]{%
\begin{minipage}{1.05\linewidth}#2\end{minipage}};%
\end{tikzpicture}%
\end{center}%
}
\begin{document}
\mybox{\textlatin{\blindtext}}
\mybox[red]{\textlatin{\blindtext}}
\mybox[blue]{\textlatin{\blindtext}}
\end{document}
Código:mdframed
\documentclass{report}
\usepackage[greek]{babel}
\usepackage{xcolor}
\usepackage{blindtext}
\usepackage[framemethod=tikz]{mdframed}
\newcommand{\mybox}[2][]{%
\begin{mdframed}[backgroundcolor=green!70,roundcorner=10.0pt, #1]
#2%
\end{mdframed}
}%
\begin{document}
\mybox{\textlatin{\blindtext}}
\mybox[backgroundcolor=red!40]{\textlatin{\blindtext}}
\mybox[backgroundcolor=blue!25]{\textlatin{\blindtext}}
\end{document}
Respuesta2
Porque ya usas el paquete tikzcaja de coloreses otra alternativa. La página 12 del Manual describe "mybox" como:
\newtcolorbox[⟨init options⟩]{⟨name⟩}[⟨number⟩][⟨default⟩]{⟨options⟩}
Crea un nuevo entorno⟨name⟩
basado entcolorbox
. Básicamente,\newtcolorbox
funciona como\newenvironment
. Esto significa que el nuevo entorno⟨name⟩
opcionalmente toma⟨number⟩
argumentos, donde⟨default⟩
está el valor predeterminado para el primer argumento opcional. Se⟨options⟩
entregan al tcolorbox subyacente.
Los teoremas se establecen con \tcbuselibrary{theorems}
(ver página 185 y siguientes).
\documentclass[a4paper]{report}
\usepackage[greek]{babel}
\usepackage[iso-8859-7]{inputenc}
\usepackage{xcolor}
\usepackage{blindtext}
\usepackage{tikz,tkz-tab,amsmath}
\usepackage{tcolorbox}
\newtcolorbox{mybox}{colback=red!5!white,colframe=red!75!black}
\newtcolorbox{mybox_1}{colback=blue!5!white,colframe=blue!75!black}
\newtcolorbox{mybox_2}{colback=green!5!white,colframe=green!75!black}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=section]{mytheo}{My Theorem}%
{colback=green!5,colframe=green!35!black,fonttitle=\bfseries}{th}
\begin{document}
\chapter{Watt}
\section{James}
\begin{mybox}
\textlatin{This is my own box.}
\end{mybox}
\begin{mybox_1}
This is my own box.
\end{mybox_1}
\begin{mybox_2}
\begin{equation}
V= \pi \cdot r^{2} \cdot h
\end{equation}
\end{mybox_2}
\begin{mytheo}{This is my title}{theoexample}
\textlatin{This is the text of the theorem. The counter is automatically assigned and, in this example, prefixed with the section number. This theorem is numbered with \ref{th:theoexample} and is given on page\pageref{th:theoexample}.}
\end{mytheo}
\end{document}