1

Hi I am using a program called xcircuit to make circuit diagrams and I cant seem to get the figure centered. I have tried \begin{center}, \centering. I have tried messing with \flushleft but it needs to be flushleft for the words to line up in the figure (see attached image) These commands work when i use \includegraphics. I know its not a bounding box problem. Thanks for your help here is the code:

\documentclass[]{article}
\usepackage{graphicx,epstopdf}
\usepackage{epsfig}
\usepackage{float}
\begin{document}
\begin{figure}[H]
\centering
 \input{hvdc}
 \caption{CIGR\'E Idealized Rectifier Station}
 \label{fig:hvdc}
\end{figure}

\begin{figure}[H]
\begin{center}
 \input{hvdc}
 \end{center}
 \caption{CIGR\'E Idealized Rectifier Station}
 \label{fig:hvdc}
\end{figure}
\end{document}

Here is the code generated by Xcircuit for hvdc.tex

\def\putbox#1#2#3{\makebox[0in][l]{\makebox[#1][l]{}\raisebox{\baselineskip}[0in][0in]{\raisebox{#2}[0in][0in]{#3}}}}
\def\rightbox#1{\makebox[0in][r]{#1}}
\def\centbox#1{\makebox[0in]{#1}}
\def\topbox#1{\raisebox{-\baselineskip}[0in][0in]{#1}}
\def\midbox#1{\raisebox{-0.5\baselineskip}[0in][0in]{#1}}
\begin{flushleft}
\epsfig{file=C:/Users/kasun/Desktop/center_pic/hvdc.eps}\\
% translate x=1222 y=-12 scale 0.38
\putbox{2.46in}{1.27in}{$1000 kV$}%
\putbox{0.42in}{1.08in}{$345 kV$}%
\putbox{0.42in}{0.91in}{$50 Hz$}%
\putbox{1.00in}{2.08in}{$345 kV:422 kV$}%
\putbox{0.25in}{0.49in}{$P_{ac}$}%
\putbox{1.17in}{1.24in}{$P_{6pulse}$}%
\putbox{1.17in}{0.24in}{$P_{6pulse}$}%
\putbox{2.34in}{0.08in}{$P_{dc}$}%
\end{flushleft}

enter image description here

  • 1
    comment out \begin{flushleft} and \end{flushleft} lines in hvdc.tex then you may get the figure centered. you might be better off with circuitikz package. – texenthusiast Feb 23 '14 at 0:02
  • Still a problem? I cannot test, as I don't have the EPS-files, but does it work if you add \usepackage{varwidth}, and replace \begin{flushleft}/\end{flushleft} with \begin{varwidth}{\linewidth}/\end{varwidth}? – Torbjørn T. Mar 19 '14 at 0:27
1

made comment into answer

comment out \begin{flushleft} and \end{flushleft} lines inhvdc.tex then you may get the figure centered. you might be better off with circuitikz package. http://www.ctan.org/pkg/circuitikz

  • Thanks for your answer , but if I don't use flush left the text wont align properly with the picture – Kasun Mar 7 '14 at 2:36
  • @Kasun In that case wrap the text only in flushleft environment and leave the figure separately. BTW epsfig is a very old package it's superseded by graphicx and avoid xcircuit if possible as it generates outdated latex code. Use circuitikz package – texenthusiast Mar 7 '14 at 5:39

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.