Math & Science ⇒ Small Squares with special Filling
-
- Posts: 14
- Joined: Tue Aug 07, 2012 2:50 pm
Small Squares with special Filling
I proposed my wife to re-format her PhD thesis in LaTeX, but today she challenged me with this difficult figure legend: If there is a way to do this I would be really happy to know, as the submission date is very soon. I would be surprised, however... In Word it's made with rectangles, not with special characters.
Thanks in advance
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Small Squares with special Filling
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 14
- Joined: Tue Aug 07, 2012 2:50 pm
Small Squares with special Filling
The example I provided did not show the right thing. Can you have another look? Now I edited the link and made it as an image...
Sorry
Thanks for the fast reply
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Small Squares with special Filling
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 14
- Joined: Tue Aug 07, 2012 2:50 pm
Small Squares with special Filling
Yes indeed it seems to be possible with tikZ. Thanks. I am now reading the manual. However it seems not too straightforward at first glance to get the thing aligned with the text, within a figure caption...localghost wrote:My last reply still applies.
I know I'm asking a lot here, but if somebody efficient in this package could provide me with an example code that I can modify, this would save me a sleepless night...
Thanks anyway. This is one of the best communities of the web!
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Small Squares with special Filling
I'd suggest that you start on your own and report back with some code when running into trouble. So we would be able to do corrections almost instantly. Otherwise this sounds like "Do this for me", you know.sdelandtsheer wrote:[…] I know I'm asking a lot here, but if somebody efficient in this package could provide me with an example code that I can modify, this would save me a sleepless night. […]
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 14
- Joined: Tue Aug 07, 2012 2:50 pm
Re: Small Squares with special Filling
Thanks a lot
-
- Posts: 14
- Joined: Tue Aug 07, 2012 2:50 pm
Small Squares with special Filling
Code: Select all
\documentclass{article}
\usepackage{tikz}
\begin{document}
Figure 1: Structure of the GR gene (NR3C1; OMIM + 138040; NR3C1; 5q31-q32), the potential mRNA transcripts and the binding sites within the CpG island.
Panel A The genomic structure of the GR.
\begin{tikzpicture}
\draw (0,0) rectangle (0.33,0.33);
\draw[gray, ultra thick](0.05,0) -- (0.05,0.33) (0.17,0) -- (0.17,0.33) (0.29,0) -- (0.29,0.33);
\end{tikzpicture}
5' untranslated distal exons;
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Small Squares with special Filling
tikzpicture
environment.
Code: Select all
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{patterns}
\newcommand*{\fillbox}[1][white]{%
\tikz\draw[fill=#1] (0,0) rectangle (1.75ex,1.75ex);%
}
\newcommand{\patternbox}[2][black]{%
\tikz\draw[pattern=#2,pattern color=#1] (0,0) rectangle (1.75ex,1.75ex);%
}
\begin{document}
The quick brown fox jumps over the pazy dog (\patternbox[gray]{grid}). The quick brown fox jumps over the pazy dog. (\fillbox[gray!50]).
\end{document}
pattern
option simplifies a different style for the boxes. For an overview of available patterns take a look at Section 42 of the pgf/tikZ manual.- Attachments
-
- The resulting output.
- tikZ-filled-boxes.png (7.99 KiB) Viewed 6552 times
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10