3

I would like to draw lattice models such as these

lattice model 1

enter image description here

In LaTeX, however, I'm not sure where to start from. Is there a way to draw these things without going point by point, line by line, etc., in TikZ?

Generally, I would like to be able to draw tight binding models and label different parts of them (hopping, site energies, interactions, ...) while being able to add details such as the nice red-dotted lines in the pictures, however, given their complexity I was wondering if there were shortcuts.

Edit:

So far, I managed to do this:

enter image description here

with this code:

\documentclass{article}
\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}
\pagestyle{empty}
\usepackage{miller}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc}


\begin{document}

% set view angle
\tdplotsetmaincoords{0}{0}% rot x rot z

\begin{tikzpicture}[tdplot_main_coords,scale=1.5,
axis/.style={thick, ->, >=stealth'}]

\def \s {0.0}     % defines shear of z along y (instead of angles), for orthogonal systems: 0
\def \su {-0.0}   % defines shear of x along y (instead of angles), for orthogonal systems: 0
\def \a {3}       % unit cells along a (only integers!)
\def \b {3}       % unit cells along b (only integers!)

\def \d {0.1}     % clusterization differential

%real space lattice

 \foreach \u in {0,1,...,\a}
    \foreach \v in {0,1,...,\b}
        \draw (\u,0) -- (\u+\su*\v,\v); 
% lattice directions parallel to a
 \foreach \u in {0,1,...,\a}
    \foreach \v in {0,1,...,\b}
        \draw (0+\su*\v,\v) -- (\u+\su*\v,\v); 


\foreach \u in {0,1,...,\a}
   \foreach \v in {0,1,...,\b}
       \draw plot [mark=*, mark size=1] coordinates{(\u+\su*\v,\v)};

%clusterization


%left
\draw[dashed,red] (-\d,-\d) -- (-\d,1+\d); 
%right
\draw[dashed,red] (1+\d,-\d) -- (1+\d,1+\d); 
%top
\draw[dashed,red] (-\d,1+\d) -- (1+\d,1+\d); 
%bottom
\draw[dashed,red] (-\d,-\d) -- (1+\d,-\d);


%left
\draw[dashed,red] (-\d+2,-\d) -- (-\d+2,1+\d); 
%right
\draw[dashed,red] (1+\d+2,-\d) -- (1+\d+2,1+\d); 
%top
\draw[dashed,red] (-\d+2,1+\d) -- (1+\d+2,1+\d); 
%bottom
\draw[dashed,red] (-\d+2,-\d) -- (1+\d+2,-\d);


%left
\draw[dashed,red] (-\d,-\d+2) -- (-\d,1+\d+2); 
%right
\draw[dashed,red] (1+\d,-\d+2) -- (1+\d,1+\d+2); 
%top
\draw[dashed,red] (-\d,1+\d+2) -- (1+\d,1+\d+2); 
%bottom
\draw[dashed,red] (-\d,-\d+2) -- (1+\d,-\d+2);


%left
\draw[dashed,red] (-\d+2,-\d+2) -- (-\d+2,1+\d+2); 
%right
\draw[dashed,red] (1+\d+2,-\d+2) -- (1+\d+2,1+\d+2); 
%top
\draw[dashed,red] (-\d+2,1+\d+2) -- (1+\d+2,1+\d+2); 
%bottom
\draw[dashed,red] (-\d+2,-\d+2) -- (1+\d+2,-\d+2);



\draw (1,0) -- node[left] {$t$}  (1,1);
\draw (0,1) -- node[below] {$t$}  (1,1);

\draw (1,1) -- node[above] {$te^{ik_x}$}  (2,1);
\draw (1,1) -- node[left] {$te^{ik_y}$}  (1,2);


\end{tikzpicture}

\end{document}

However, I don't know how to loop through \a and \b in order to draw the red-dashed lines systematically since I'm not sure how to divide those quantities by two and then take their integer part in LaTeX, is there a way?

4
  • 4
    Welcome. // Right, Tikz is a/the way to do it. For a start you should look for \node, \draw, \foreach and \pic. Once you have some preliminary result, feel free to EDIT your question and append said code. Thank you Commented Aug 12, 2024 at 14:46
  • 2
    If you don’t want to draw it line by line and dot by dot, you need to explain the software you want to use what it is supposed to draw upon entering a certain input. I am unsure about the existence of a package that you could use here, so you would indeed need to use basic TikZ more or less. But you can always create your custom macros and maybe make use of some loops to reduce the amount of needed code. Since I don’t know anything about these diagrams, I can’t help you much. Commented Aug 12, 2024 at 14:58
  • Great so far 👍. // For the red squares look up rectangle, which saves you many lines of code. Commented Aug 12, 2024 at 16:03
  • Have a look here, where I illustrated how to apply refactoring tex.stackexchange.com/a/724019/24579, which is constant generalization and absorption of code. Commented Aug 12, 2024 at 16:07

1 Answer 1

2

Here's a way to modify your current code. Some remarks.

Not sure why you need 3D for the screenshots you included.

Better use class standalone, which will gives you more freedom later. (search under my user name for standalone and graphicx: example 1, example 2 )

As a general rule, don't load packages, you don't need for the current code.

In the loop with \a and \b, what did you want to do: plot between coordinates? Or did you want nodes (labels) there?

Please see my remarks in the comments, below.

result

%\documentclass{article}

\documentclass[10pt,border=3mm,tikz]{standalone}
%\usepackage{amsmath}
%\usepackage[dvipsnames]{xcolor}
%\pagestyle{empty}
%\usepackage{miller}
%\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc}


\begin{document}

% set view angle
\tdplotsetmaincoords{0}{0}% rot x rot z

\begin{tikzpicture}[tdplot_main_coords,scale=1.5,
axis/.style={thick, ->, >=stealth'}]

\def \s {0.0}     % defines shear of z along y (instead of angles), for orthogonal systems: 0
\def \su {-0.0}   % defines shear of x along y (instead of angles), for orthogonal systems: 0
\def \a {3}       % unit cells along a (only integers!)
\def \b {3}       % unit cells along b (only integers!)

\def \d {0.1}     % clusterization differential

%real space lattice

 \foreach \u in {0,1,...,\a}
    \foreach \v in {0,1,...,\b}
        \draw (\u,0) -- (\u+\su*\v,\v); 
% lattice directions parallel to a
 \foreach \u in {0,1,...,\a}
    \foreach \v in {0,1,...,\b}
        \draw (0+\su*\v,\v) -- (\u+\su*\v,\v); 


\foreach \u in {0,1,...,\a}
   \foreach \v in {0,1,...,\b}
%       \draw plot [mark=*, mark size=1] coordinates{(\u+\su*\v,\v)};
       \node at (\u+\su*\v,\v) {*}; % did you mean this?

%clusterization


%%left
%\draw[dashed,red] (-\d,-\d) -- (-\d,1+\d); 
%%right
%\draw[dashed,red] (1+\d,-\d) -- (1+\d,1+\d); 
%%top
%\draw[dashed,red] (-\d,1+\d) -- (1+\d,1+\d); 
%%bottom
%\draw[dashed,red] (-\d,-\d) -- (1+\d,-\d);
%left

% ~~~ 1st refactoring ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%\draw[dashed,red] (-\d,-\d) -- (-\d,1+\d) -- (1+\d,1+\d)  -- (1+\d,1+\d) -- (1+\d,-\d) -- cycle;

% ~~~ 2nd refactoring ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\draw[dashed,red] (-\d,-\d)     rectangle (1+\d,1+\d);

\draw[dashed,red] (-\d+2,-\d)   rectangle (1+\d+2,1+\d);
\draw[dashed,red] (-\d,-\d+2)   rectangle (1+\d,1+\d+2); 
\draw[dashed,red] (-\d+2,-\d+2) rectangle (1+\d+2,1+\d+2); 



\draw (1,0) -- node[left] {$t$}  (1,1);
\draw (0,1) -- node[below] {$t$}  (1,1);

\draw (1,1) -- node[above] {$te^{ik_x}$}  (2,1);
\draw (1,1) -- node[left] {$te^{ik_y}$}  (1,2);


\end{tikzpicture}

P.S.: A 3rd refactoring leads to this code:

%% ~~~ 2nd refactoring ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%\draw[dashed,red] (-\d  , -\d)     rectangle (1+\d,   1+\d);
%
%\draw[dashed,red] (-\d+2, -\d)     rectangle (1+\d+2, 1+\d);
%\draw[dashed,red] (-\d  , -\d+2)   rectangle (1+\d,   1+\d+2); 
%\draw[dashed,red] (-\d+2, -\d+2)   rectangle (1+\d+2, 1+\d+2); 

% ~~~ 3rd refactoring
\foreach \i/\j in {0/0, 0/2, 2/0, 2/2}
    \draw[dashed,red] (-\d+\i, -\d+\j)  rectangle (1+\d+\i,  1+\d+\j);

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.