Math & ScienceSmall Squares with special Filling

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
sdelandtsheer
Posts: 14
Joined: Tue Aug 07, 2012 2:50 pm

Small Squares with special Filling

Post by sdelandtsheer »

Hello,

I proposed my wife to re-format her PhD thesis in LaTeX, but today she challenged me with this difficult figure legend:
caption-legend.jpg
caption-legend.jpg (118.08 KiB) Viewed 6552 times
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
Last edited by localghost on Wed Sep 12, 2012 7:07 pm, edited 3 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

Post by localghost »

Could be done with pgf/tikZ. The package manual should be a good start.


Thorsten
sdelandtsheer
Posts: 14
Joined: Tue Aug 07, 2012 2:50 pm

Small Squares with special Filling

Post by sdelandtsheer »

localghost wrote:Could be done with pgf/tikZ. The package manual should be a good start.


Thorsten
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
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Small Squares with special Filling

Post by localghost »

My last reply still applies.
sdelandtsheer
Posts: 14
Joined: Tue Aug 07, 2012 2:50 pm

Small Squares with special Filling

Post by sdelandtsheer »

localghost wrote:My last reply still applies.
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...

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!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Small Squares with special Filling

Post by localghost »

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. […]
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
Posts: 14
Joined: Tue Aug 07, 2012 2:50 pm

Re: Small Squares with special Filling

Post by sdelandtsheer »

Got it. It was easier than expected. Great package I'll post some code later for the example

Thanks a lot
sdelandtsheer
Posts: 14
Joined: Tue Aug 07, 2012 2:50 pm

Small Squares with special Filling

Post by sdelandtsheer »

Here it is, for the beginning :

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}
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Small Squares with special Filling

Post by localghost »

You can simplify that a bit by defining some useful macros in order to avoid always inserting a 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}
The 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.
The resulting output.
tikZ-filled-boxes.png (7.99 KiB) Viewed 6554 times
Post Reply