LaTeX forum ⇒ Graphics, Figures & TablesTikZ | Configuration of Example Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Location: Aarhus, Denmark

TikZ | Configuration of Example

Postby svend_tveskaeg » Tue Oct 09, 2012 7:01 am

Hi all.

The example here is just great (and even better with the implementation in the comment).

I would, however, like to have all the sides on a cube in the same color but have the color change in each layer of cubes. (I hope it makes sense.)

I have never used TikZ (and I do not have the time to learn it at the moment), so I would be very glad if someone would change the code for me.

Thank you in advance!
Last edited by svend_tveskaeg on Tue Oct 09, 2012 9:24 pm, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Location: Aarhus, Denmark

Postby svend_tveskaeg » Tue Oct 09, 2012 8:58 pm

I am not sure if people are quite because

(1) there is no MWE directly in the thread,
(2) no one can solve my problem, or
(3) something else.

Therefore, I will eliminate the first possibility:

  1. \documentclass{article}
  2.  
  3. \usepackage[danish]{babel}
  4. \usepackage{ifthenx}
  5. \usepackage{verbatim}
  6. \usepackage{tikz}
  7.  
  8. % Three counters
  9. \newcounter{x}
  10. \newcounter{y}
  11. \newcounter{z}
  12. % The angles of x,y,z-axes
  13. \newcommand{\xaxis}{210}
  14. \newcommand{\yaxis}{-30}
  15. \newcommand{\zaxis}{90}
  16. % The top side of a cube
  17. \newcommand{\topside}[3]{%
  18. \fill[fill=yellow, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
  19. shift={(\zaxis:#3)}] (0,0) -- (30:1) -- (0,1) --(150:1)--(0,0);
  20. }
  21. % The left side of a cube
  22. \newcommand{\leftside}[3]{%
  23. \fill[fill=red, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
  24. shift={(\zaxis:#3)}] (0,0) -- (0,-1) -- (210:1) --(150:1)--(0,0);
  25. }
  26. % The right side of a cube
  27. \newcommand{\rightside}[3]{%
  28. \fill[fill=blue, draw=black,shift={(\xaxis:#1)},shift={(\yaxis:#2)},
  29. shift={(\zaxis:#3)}] (0,0) -- (30:1) -- (-30:1) --(0,-1)--(0,0);
  30. }
  31. % The cube
  32. \newcommand{\cube}[3]{%
  33. \topside{#1}{#2}{#3} \leftside{#1}{#2}{#3} \rightside{#1}{#2}{#3}
  34. }
  35. % Definition of \planepartition
  36. \newcommand\planepartition[1]{
  37. \setcounter{x}{-1}
  38. \foreach \a in {#1} {
  39. \addtocounter{x}{1}
  40. \setcounter{y}{-1}
  41. \foreach \b in \a {
  42. \addtocounter{y}{1}
  43. \setcounter{z}{-1}
  44. \foreach \c in {0,...,\b} {
  45. \addtocounter{z}{1}
  46. \ifthenelse{\c=0}{\setcounter{z}{-1},\addtocounter{y}{0}}{
  47. \cube{\value{x}}{\value{y}}{\value{z}}}
  48. }
  49. }
  50. }
  51. }
  52.  
  53. \begin{document}
  54.  
  55. \begin{tikzpicture}
  56. \planepartition{{5,3,2,2},{4,2,2,1},{2,1},{1}}
  57. \end{tikzpicture}
  58.  
  59. \end{document}
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Tue Oct 09, 2012 9:10 pm

You seem to assume that those who are able to help always can invest their time especially in your problems. That is not the case. m(


Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Location: Aarhus, Denmark

Postby svend_tveskaeg » Tue Oct 09, 2012 9:21 pm

localghost wrote:You seem to assume that those who are able to help always can invest their time ...

No I do not. That is why I wrote (3).

localghost wrote:... especially in your problems

If I have given that impression in my previous posts, I apologise. That was not my indend.

P.S. I am glad whenever someone helps me. As I said before, I just tried to eliminate one of the possible reason why my post was not answered.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Tue Oct 09, 2012 9:39 pm

My bet would be the following sentence:
I would be very glad if someone would change the code for me.


Questions that sound like “please do it for me” are very unlikely to be answered, the more so the more direct they are (even if they are more honest that way and regardless of the reasons behind them...). At least that's my experience.

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am
Location: Aarhus, Denmark

Postby svend_tveskaeg » Tue Oct 09, 2012 9:51 pm

That makes sense.

However, I have no intend of people coming foreward afterwards and claming that they were duped; I am telling it at it is. If that means that I will not get any help, then so be it.

Since I do now know TikZ at all and really like the code above with the alternation that I mentioned, that is how I do it.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Tue Oct 09, 2012 10:53 pm

And because you are so impatient, you have posted this also on {TeX} SX? Our administrator has written down some interesting thoughts in this regard.

Board Rules (Section 4.1) wrote:A crossposting is always contra-productive. But there is nothing really against it as long as it is mentioned. This means that a direct link has to be added. So other users who want to help are preserved from double efforts and waste of time.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Tue Oct 09, 2012 10:58 pm

However, I have an (untested) idea: change all colors (yellow, blue, red) into cubecolor and add
  1. \colorlet{cubecolor}{red!\c0}
(or similar) right beneath
  1. \addtocounter{z}{1}


This should draw each layer in a different shade of red.

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
Stefan Kottwitz
Site Admin
Posts: 7804
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Tue Oct 09, 2012 11:33 pm

Very good, Clemens! I tested it, and this gives:
cubes.png
cubes.png (12.4 KiB) Viewed 1440 times

Perhaps post it to the other site. If you don't have TeX at hand to compile, just use this image there as well.

Stefan
Site admin

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Wed Oct 10, 2012 12:08 am

Stefan_K wrote:Perhaps post it to the other site.


I have, together with a second idea I had.
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 8 guests