4

I´m generating any grpahs... and I´m playing with any linewidhts values so I would like to type on the beginning of the .TEX a line similar to

width1=0.1cm
width2=0.15cm
width2=0.20cm

to avoid chaging all the values of linewidth trough all the lines in the graphs. So, I would change only, and I view all the lines with that width.

   width1=0.32cm 

How can I do this?

I suposse this is easy, but I can´t find the answer.

-- That´s my doubt --- and in the next lines I type my .tex file, where I can´t reach a good way to do an amount as a parameter

\documentclass[12pt,a4paper]{article}
\usepackage[top=2.5cm, left=3.5cm, bottom=2.5cm, right=2.5cm]{geometry}  % Margenes de la normativa TFG

\usepackage{setspace} % para que no afecte el interlineado a las notas de pié de página
\setstretch{1.5}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage{amsmath,amsfonts,amssymb,latexsym}
\usepackage{eurosym}
\usepackage{graphicx}
\usepackage{verbatim}

\usepackage{hyperref}
\hypersetup{colorlinks=true, urlcolor=blue}

\usepackage{xcolor}
\usepackage{mathpazo}       % Fuente MathPazo
\usepackage{datetime}       % paquete para configurar formato de fecha y hora
\settimeformat{ampmtime}
\renewcommand*{\noon}{\pmname}
\spanishdecimal{.}
% ----------------------  PSTRICKS ---------------
\usepackage{pstricks}
\usepackage{pst-plot,pst-3dplot,pst-node,pst-tree,pst-grad,pst-coil,pst-text,pst-3d,pst-eps,pst-fill,pstricks-add,multido}
% -------- Paquetes de pst-all \usepackage{pst-all}   paquete pstricks para las figuras en postcript
\usepackage{pst-node}
\usepackage{pst-eps}
\usepackage{pstricks-add}
% ---- Fin Paquetes de pst-all

w1=0.085cm          (HERE I WANT TO DEFINE A PARAMETER)
w2=0.1cm                (HERE I WANT TO DEFINE A PARAMETER)
w3=0.15cm             (HERE I WANT TO DEFINE A PARAMETER)
w4=0.30cm            (HERE I WANT TO DEFINE A PARAMETER)


\begin{document}
\psset{xunit=1cm,yunit=1cm}
  \begin{pspicture}(-0,-0)(7.28,4.5) %\malla
 \psframe[fillcolor=lightgray,fillstyle=solid,linestyle=none](-.0,0)(7.28,4.5)

 \rput(1,1){\circlenode{1}{\textcolor{black}{1}}}
 \rput(1,3){\circlenode{2}{\textcolor{black}{2}}}
 \rput(3,2){\circlenode{3}{\textcolor{black}{3}}}
 \rput(3,4){\circlenode{4}{\textcolor{black}{4}}}
 \rput(5,1){\circlenode{5}{\textcolor{black}{5}}}
 \rput(5,3){\circlenode{6}{\textcolor{black}{6}}}
 \rput(7,2){\circlenode{7}{\textcolor{black}{7}}}

 \ncline[linewidth=w1]{-}{1}{2}\naput{\scriptsize $2$} (IN THIS LINE I WANT TO USE A PARAMETER)
 \ncline{-}{1}{3}\naput{\scriptsize $6$}
 \ncline{-}{1}{4}\naput{\scriptsize $4$}
 \ncline{-}{1}{5}\naput{\scriptsize $6$}
 \ncline{-}{2}{4}\naput{\scriptsize $7$}
 \ncline[linewidth=w2]{-}{2}{3}\naput{\scriptsize $3$} (IN THIS LINE I WANT TO USE A PARAMETER)
 \ncline[linewidth=w3]{-}{3}{4}\naput{\scriptsize $5$} (IN THIS LINE I WANT TO USE A PARAMETER)
 \ncline{-}{3}{5}\naput{\scriptsize $4$}
 \ncline{-}{3}{6}\naput{\scriptsize $9$}
 \ncline{-}{3}{7}\naput{\scriptsize $3$}
 \ncline{-}{4}{6}\naput{\scriptsize $3$}
 \ncline[linewidth=0.12cm]{-}{4}{5}\naput{\scriptsize $4$}
 \ncline[linewidth=0.12cm]{-}{5}{6}\naput{\scriptsize $6$}
 \ncline{-}{5}{7}\naput{\scriptsize $8$}
 \ncline[linewidth=0.12cm]{-}{6}{7}\naput{\scriptsize $4$}

 \nccurve[angleA=335,angleB=255,linewidth=0.12cm]{-}{1}{7}\naput{\scriptsize $4$}

 \end{pspicture}
\end{document}
6
  • 1
    width1=0.32cm and width2=\dimexper\0.2\width1\relax is what you want? – user11232 Apr 15 '14 at 11:01
  • @HarishKumar: I think the question is more about defining new keys with PSTricks. – Claudio Fiandrino Apr 15 '14 at 11:09
  • \harish-kumar That solutions gives me problem!! No solution – Mika Ike Apr 15 '14 at 11:56
  • @Mika Could you please edit your post and make it fully compilable example? It would help the solvers tremendously. – Malipivo Apr 15 '14 at 12:04
  • \malipivo ok, I have done it, but we have just the solution by Christoph – Mika Ike Apr 15 '14 at 12:42
2

With PSTricks you can use \pslinewidth, which is the current linewidth. If you use that through the document, you can later scale the linewidth of all lines.

\documentclass[pstricks]{standalone}

\begin{document}
\begin{pspicture}(5,5)
  \psset{linewidth=3pt}
  \psline(0,1)(5,1)
  \psline(0,2)(5,2)
  \psline[linewidth=2\pslinewidth](0,3)(5,3)
  \psline[linewidth=3\pslinewidth](0,4)(5,4)
\end{pspicture}
\end{document}

If you want to change the line properties of only a few lines, you can use e.g. \newpsstyle to define some line styles at one, centralized point in your document:

\documentclass[pstricks]{standalone}

\begin{document}
\newpsstyle{LineA}{linewidth=2\pslinewidth, linecolor=green}
\newpsstyle{LineB}{linewidth=3\pslinewidth, linecolor=red}
\begin{pspicture}(5,5)
  \psset{linewidth=3pt}
  \psline(0,1)(5,1)
  \psline(0,2)(5,2)
  \psline[style=LineA](0,3)(5,3)
  \psline[style=LineB](0,4)(5,4)
\end{pspicture}
\end{document}

enter image description here

Just to mention a few possibilities.

3
  • Fantastic Solution!! Thank you. This is neccessary defined in each pstricks image, or Can I define for all the .TEX for every pstricks images. – Mika Ike Apr 15 '14 at 12:43
  • 1
    You can of course define a file mysettings.tex which contains only the \newpsstyle or \newpsobject (see Herbert's answer) definitions and load that into every other file with \input{mysettings}. – Christoph Apr 15 '14 at 12:49
  • a curisity !! for objects and styles You must use \newpsobjet and \newpsstyle. and... where can I find more things that can be defined in the way you show me? – Mika Ike Apr 15 '14 at 14:14
2
\documentclass{article}
\usepackage{pstricks}
\newpsobject{pslineA}{psline}{linewidth=6\pslinewidth, linecolor=green}
\newpsobject{pslineB}{psline}{linewidth=10\pslinewidth, linecolor=red}

\begin{document}
\begin{pspicture}(5,5)
  \psline(0,1)(5,1)
  \psline[linewidth=1mm](0,2)(5,2)
  \pslineA(0,3)(5,3)
  \pslineB(0,4)(5,4)
\end{pspicture}
\end{document}

enter image description here

1
  • Thank you. I´m sorry for not be available choose 2 answers as THE ANSWER! It´s fantastic have 2 good answers. – Mika Ike Apr 15 '14 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.