LaTeX forum ⇒ Text FormattingCustom/Macro Opacity Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

Custom/Macro Opacity

Postby LaTexLearner » Sun Sep 20, 2015 4:06 am

Is there any way to set a custom opacity?

My laser printer just printed some documents I created and I realized that the opacity was too low. Now I have to go back and change a whole lot of opacity settings. If only I'd had a custom macro/setting for that... Is that possible?

Something like \newopacity{\answeropacity}{0.8}?

  1. \documentclass{article}
  2.  
  3. % This didn't work...
  4. %\newopacity{\answeropacity}{0.8}
  5.  
  6. \usepackage{tikz}
  7.  
  8. \begin{document}
  9.  
  10. \begin{enumerate}
  11. \item Draw a length that represents two starting from zero.
  12.  
  13. \tikz
  14. {
  15. \draw (0,0)--(4,0);
  16. \foreach \x in {0,...,4}
  17. {
  18. \draw (\x,-0.2)--(\x,0.2);
  19. \node[below] at (\x,-0.3) {\x};
  20. }
  21. \fill[opacity=0.5] (0,0) rectangle (2,0.2);
  22. }
  23.  
  24. \item Draw a length that represents four starting from zero.
  25.  
  26. \tikz
  27. {
  28. \draw (0,0)--(5,0);
  29. \foreach \x in {0,...,5}
  30. {
  31. \draw (\x,-0.2)--(\x,0.2);
  32. \node[below] at (\x,-0.3) {\x};
  33. }
  34. \fill[opacity=0.5] (0,0) rectangle (4,0.2);
  35. }
  36.  
  37. \end{enumerate}
  38.  
  39. \end{document}
Last edited by LaTexLearner on Mon Sep 21, 2015 2:58 am, edited 1 time in total.

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Sun Sep 20, 2015 10:17 pm

Use

  1. \newcommand{\answeropacity}{0.8}


and then in your TikZ

  1. \fill[opacity=\answeropacity]
site moderator & package author

LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

Postby LaTexLearner » Mon Sep 21, 2015 2:58 am

Awesome. I look forward to trying that tonight.

LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

Postby LaTexLearner » Tue Sep 22, 2015 10:30 pm

Worked perfectly, thanks! :)


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests