Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need a way to correctly align the escaped strings that I put inside of this listing. The problem is that they are presented right aligned. I want that this lines keep the indentation of the previous code. For example:

 line of code 
 line of code
        line of code
        \vdots correctly aligned escaped string

what I have is something like

 line of code 
 line of code
        line of code
                           \vdots right aligned escaped string

the real code is this:

\lstset{language=[Sharp]C,,basicstyle=\footnotesize, showspaces=false,showtabs=false,,breaklines=true,showstringspaces=false,breakatwhitespace=true,frame=trBL, escapeinside={(*@}{@*)}}
\begin{lstlisting}
 namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        string oldName;
        int index = 0;
        public Form1()
        {
            InitializeComponent();
            listView1.LabelEdit = true;
            listView1.MultiSelect = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listView1.Items.Add("xd"+index);
            index++;
            listView1.Items[listView1.Items.Count - 1].Selected = true;
            (*@  $\vdots$ @*)
            (*@  $\vdots$ Comparaciones similares a la anterior. Compactadas por brevedad. @*)
            (*@  $\vdots$ @*)

        }
share|improve this question
2  
While it is good that you include some code, it is much better to include a minimal working example---a complete chunk of code that can be copied and compiled and which exhibits your issue whilst containing nothing not needed to do so. –  vanden May 15 '11 at 14:19
    
add the documentclass and begin{document} and end{document} to the code that i expose. –  mjsr May 15 '11 at 14:26
1  
Yes, I and everyone else who might try to help you could each take a few seconds to do that. Or, you, the person seeking help, could take a few seconds to do that for all of those who might help you. One alternative is both much more efficient and polite. –  vanden May 15 '11 at 16:50
add comment

1 Answer

up vote 0 down vote accepted

I can't reproduce what you're seeing with the following minimal example (though the line breaks on the frame are weird). There's probably another package you're using that's causing the problem.

\documentclass{article}
\usepackage{listings}
\begin{document}
\lstset{language=[Sharp]C,,basicstyle=\footnotesize, showspaces=false,showtabs=false,,breaklines=true,showstringspaces=false,breakatwhitespace=true,frame=trBL, escapeinside={(*@}{@*)}}
\begin{lstlisting}
 namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        string oldName;
        int index = 0;
        public Form1()
        {
            InitializeComponent();
            listView1.LabelEdit = true;
            listView1.MultiSelect = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listView1.Items.Add("xd"+index);
            index++;
            listView1.Items[listView1.Items.Count - 1].Selected = true;
            (*@  $\vdots$ @*)
            (*@  $\vdots$ Comparaciones similares a la anterior. Compactadas por brevedad. @*)
            (*@  $\vdots$ @*)

        }
\end{lstlisting}
\end{document}

enter image description here

share|improve this answer
    
you are right the problem with the alignment was with the tabs characters. I don't know why but if i use tabs instead of spaces i get the bad result, i.e the text right aligned, if i use spaces then i get the result that you expose. Weird thing. Can you give me some hints to avoid break the external box? –  mjsr May 15 '11 at 14:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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