
Sin usar phantom ¿cómo puedo colocar el texto comenzando de abajo hacia arriba?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\def\n{.5}
\definecolor{aqua}{rgb}{0.0, 1.0, 1.0}
\definecolor{carnationpink}{rgb}{1.0, 0.65, 0.79}
\begin{tikzpicture}
%%%Ones Value
\foreach \x/\xtext in {1/\textcolor{black}
{hundreds\phantom{xxxx}},2/\textcolor{black}
{tens},3/\textcolor{blue}{ones}}
\draw[xshift=.5*\x cm,fill=aqua] (0,.5) rectangle (\n,3.5) node[midway,
rotate=90,text=blue] {\textbf{\xtext}};
\foreach \x/\d in {1/3,2/6,3/4}
\draw[xshift=.5*\x cm,fill=aqua] (0,0) rectangle (\n,\n) node[pos=.5]
{$\d$};
%%%Thousands
\foreach \x/\xtext in {0/\textcolor{black}
{Thousands\phantom{xxxx}},1/\textcolor{black}{Ten Thousands\phantom{x}}}
\draw[xshift=-.5*\x cm,fill=carnationpink] (0,.5) rectangle (\n,3.5)
node[midway, rotate=90,text=blue] {\textbf{\xtext}};
\foreach \x/\d in {0/,1/}
\draw[xshift=-.5*\x cm,fill=carnationpink] (0,0) rectangle (\n,\n) node[pos=.5] {$\d$};
\end{tikzpicture}
\end{document}
Respuesta1
Si utiliza una matriz, no es necesario codificar el archivo text width
. El ancho de los nodos se ajustará a la entrada más amplia.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,backgrounds}
\begin{document}
\definecolor{aqua}{rgb}{0.0, 1.0, 1.0}
\definecolor{carnationpink}{rgb}{1.0, 0.65, 0.79}
\begin{tikzpicture}
\matrix [matrix of nodes,nodes in empty cells,draw,
row 1/.style={nodes={rotate=90,anchor=west,font=\bfseries}}] (mat)
{
Ten Thousands & Thousands & hundreds & tens & |[text=blue]| ones\\
& & 3 & 6 & 4 \\
};
\foreach \X [count=\Y] in {2,...,5}
{\path (mat-1-\Y.center) -- (mat-1-\X.center) coordinate[midway] (h-\Y);
\draw (h-\Y|-mat.south) -- (h-\Y|-mat.north);}
\draw (mat-2-5.north -|mat.west) -- (mat-2-5.north -|mat.east);
\begin{scope}[on background layer]
\fill[carnationpink] (h-2|-mat.south) rectangle (mat.north west);
\fill[aqua] (h-2|-mat.south) rectangle (mat.north east);
\end{scope}
\end{tikzpicture}
\end{document}
O con Millones.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,backgrounds}
\begin{document}
\definecolor{aqua}{rgb}{0.0, 1.0, 1.0}
\definecolor{carnationpink}{rgb}{1.0, 0.65, 0.79}
\begin{tikzpicture}
\matrix [matrix of nodes,nodes in empty cells,draw,
row 1/.style={nodes={rotate=90,anchor=west,font=\bfseries,text
height=2.5ex,text depth=0.25ex}}] (mat)
{
Ten Millions & Millions & Hundred Thousands & Ten Thousands & Thousands & hundreds & tens & |[text=blue]| ones\\
& & & & & 3 & 6 & 4 \\
};
\foreach \X [count=\Y] in {2,...,8}
{\path (mat-1-\Y.center) -- (mat-1-\X.center) coordinate[midway] (h-\Y);
\draw (h-\Y|-mat.south) -- (h-\Y|-mat.north);}
\draw (mat-2-8.north -|mat.west) -- (mat-2-8.north -|mat.east);
\begin{scope}[on background layer]
\fill[aqua] (h-5|-mat.south) rectangle (mat.north east);
\fill[carnationpink] (h-5|-mat.south) rectangle (h-2|-mat.north east);
\fill[yellow] (h-2|-mat.south) rectangle (mat.north west);
\end{scope}
\end{tikzpicture}
\end{document}
Respuesta2
¿como esto?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains, positioning} % <--- new
\begin{document}
\def\n{.5}
\definecolor{aqua}{rgb}{0.0, 1.0, 1.0}
\begin{tikzpicture}[
node distance = 0pt, % <--- new
start chain = A going above, % <--- new
box/.style = {draw, fill=aqua, text width=#1, minimum height=6mm,
outer sep=0pt, rotate=90, on chain}, % <--- new
box/.default = 35mm
]
\node[box, text=blue] {ones}; % A-1
\node[box] {hundreds};
\node[box] {thousands}; % A-3
\foreach \i in {1,2,3}
\node[box=6mm, fill=red!30, left=of A-\i] {};
\end{tikzpicture}
\end{document}
anexo: considerando la pregunta actualizada, la primera solución debe cambiarse a:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains, positioning} % <--- new
\begin{document}
\definecolor{aqua}{rgb}{0.0, 1.0, 1.0}
\definecolor{carnationpink}{rgb}{1.0, 0.65, 0.79}
\begin{tikzpicture}[
node distance = 0pt, % <--- new
start chain = A going below, % <--- new
bbox/.style = {draw, fill=#1, text width=24mm,
minimum height=6mm, outer sep=0pt,
rotate=90, on chain}, % <--- new
sbox/.style = {draw, fill=#1, text width=3mm, align=center, % <--- new
minimum height=6mm, outer sep=0pt, % <--- new
rotate=90, on chain} % <--- new
]
\node[bbox=carnationpink] {Ten Thousands}; % A-1
\node[bbox=carnationpink] {Thousands};
\node[bbox=aqua] {hundreds};
\node[bbox=aqua] {tens};
\node[bbox=aqua, text=blue] {ones}; % A-5
\foreach \i/\j [count=\k] in {carnationpink/ , carnationpink/ , aqua/3, aqua/6, aqua/4}
\node[sbox=\i, left=of A-\k] {\rotatebox{-90}{\j}}; ]
\end{tikzpicture}
\end{document}
lo que da:
Respuesta3
No es difícil con node[right,rotate=90]
. Tenga en cuenta que lo usamos right
porque ya es rotate
d. Puedes ver por qué cuando lo usas above
en su lugar.
Esta forma sencilla garantizará un tamaño constante de los rectángulos y los textos estarán en el medio.
\documentclass[tikz,margin=3mm]{standalone}
\definecolor{aqua}{rgb}{0.0, 1.0, 1.0}
\definecolor{carnationpink}{rgb}{1.0, 0.65, 0.79}
\begin{document}
\begin{tikzpicture}[scale=0.75]
\fill[carnationpink] (0,0) rectangle (2,5);
\fill[aqua] (2,0) rectangle (5,5);
\draw (0,0) grid (5,1);
\foreach \i in {0,...,4} \draw (\i,1) rectangle (\i+1,5);
\node at (2.5,.5) {3};
\node at (3.5,.5) {6};
\node at (4.5,.5) {4};
\draw (.5,1) node[right,rotate=90] {ten thousands};
\draw (1.5,1) node[right,rotate=90] {thousands};
\draw (2.5,1) node[right,rotate=90] {hundreds};
\draw (3.5,1) node[right,rotate=90] {tens};
\draw[blue] (4.5,1) node[right,rotate=90] {ones};
\end{tikzpicture}
\end{document}
Respuesta4
No es necesario utilizar tikz
para realizar este tipo de tablas. Es mucho más fácil utilizar el tabular
medio ambiente.
\documentclass{article}
\usepackage{tikz}
\usepackage{colortbl}
\begin{document}
\def\n{.5}
\definecolor{aqua}{rgb}{0.0, 1.0, 1.0}
\definecolor{carnationpink}{rgb}{1.0, 0.65, 0.79}
\def\angle{90}
\begin{tabular}{*{2}{|>{\cellcolor{carnationpink}}l}*{3}{|>{\cellcolor{aqua}}l}|}
\hline
\rotatebox{\angle}{Ten thousands } & \rotatebox{\angle}{Thousands} & \rotatebox{\angle}{hundreds } & \rotatebox{\angle}{tens} & \rotatebox{\angle}{ones} \\
\hline
& & 3&6 & 4\\\hline
& & & & \\\hline
\end{tabular}
\end{document}