uneven tab for align text












3















How can I align program and ''(commas) in same vertical line
my code was



            item [1.]quad Identifierquad   program
item [2.]quad White_Spacequad' '


Tab is even










share|improve this question























  • Please provide a MWE that makes it easy to compile and alter your code.

    – Bubaya
    Feb 21 at 10:46
















3















How can I align program and ''(commas) in same vertical line
my code was



            item [1.]quad Identifierquad   program
item [2.]quad White_Spacequad' '


Tab is even










share|improve this question























  • Please provide a MWE that makes it easy to compile and alter your code.

    – Bubaya
    Feb 21 at 10:46














3












3








3








How can I align program and ''(commas) in same vertical line
my code was



            item [1.]quad Identifierquad   program
item [2.]quad White_Spacequad' '


Tab is even










share|improve this question














How can I align program and ''(commas) in same vertical line
my code was



            item [1.]quad Identifierquad   program
item [2.]quad White_Spacequad' '


Tab is even







align white-space






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 21 at 10:00









BawanthaBawantha

202




202













  • Please provide a MWE that makes it easy to compile and alter your code.

    – Bubaya
    Feb 21 at 10:46



















  • Please provide a MWE that makes it easy to compile and alter your code.

    – Bubaya
    Feb 21 at 10:46

















Please provide a MWE that makes it easy to compile and alter your code.

– Bubaya
Feb 21 at 10:46





Please provide a MWE that makes it easy to compile and alter your code.

– Bubaya
Feb 21 at 10:46










2 Answers
2






active

oldest

votes


















1














As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.



Note also:




  • If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.

  • I can't approve of adding quads to put extra space after the item label. If the list is not as it should be, change labelsep and (if need be) labelwidth. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.


And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.



Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.



documentclass{article}
usepackage{enumitem}

newcommand{parsedescription}[2]{%
makebox[2.5cm][l]{#1}{#2}}

begin{document}

section{Hand rolled}

This is a hand-rolled version
begin{itemize}
item Output of scanner:
begin{enumerate}
itemparsedescription{Identifier}{program}
itemparsedescription{White_Space}{' '}
end{enumerate}
end{itemize}

section{Properly done}

And this is, much more semantically correct:

newcounter{parsecounter}

newlist{parse}{description}{1}
setlist[parse]{style=sameline,
labelwidth=3cm,
leftmargin=!,
labelindent=1em,
font=normalfont,
before={%
setcounter{parsecounter}{0}%
renewcommandmakelabel[1]{%
stepcounter{parsecounter}%
arabic{parsecounter}.enspace##1}}}


begin{itemize}
item Output of scanner:
begin{parse}
item[Identifier]program
item[White_Space]' '
end{parse}
end{itemize}
end{document}


Output results






share|improve this answer

































    1














    If using a table is not an option for you, you can always fiddle around manually with phantom or hphantom, makebox and widthof, of which the latter is provided by the calc package. So, to have your " underneath the word 'program', you can do:



    documentclass{article}
    usepackage{calc}
    begin{document}
    begin{enumerate}
    item makebox[widthof{White_Space}][l]{Identifier}quad program
    item White_Space quad makebox[widthof{program}]{''}
    end{enumerate}
    end{document}


    enter image description here



    However, if this is to be a lengthy list, consider using the tabular environment.






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475969%2funeven-tab-for-align-text%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.



      Note also:




      • If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.

      • I can't approve of adding quads to put extra space after the item label. If the list is not as it should be, change labelsep and (if need be) labelwidth. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.


      And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.



      Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.



      documentclass{article}
      usepackage{enumitem}

      newcommand{parsedescription}[2]{%
      makebox[2.5cm][l]{#1}{#2}}

      begin{document}

      section{Hand rolled}

      This is a hand-rolled version
      begin{itemize}
      item Output of scanner:
      begin{enumerate}
      itemparsedescription{Identifier}{program}
      itemparsedescription{White_Space}{' '}
      end{enumerate}
      end{itemize}

      section{Properly done}

      And this is, much more semantically correct:

      newcounter{parsecounter}

      newlist{parse}{description}{1}
      setlist[parse]{style=sameline,
      labelwidth=3cm,
      leftmargin=!,
      labelindent=1em,
      font=normalfont,
      before={%
      setcounter{parsecounter}{0}%
      renewcommandmakelabel[1]{%
      stepcounter{parsecounter}%
      arabic{parsecounter}.enspace##1}}}


      begin{itemize}
      item Output of scanner:
      begin{parse}
      item[Identifier]program
      item[White_Space]' '
      end{parse}
      end{itemize}
      end{document}


      Output results






      share|improve this answer






























        1














        As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.



        Note also:




        • If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.

        • I can't approve of adding quads to put extra space after the item label. If the list is not as it should be, change labelsep and (if need be) labelwidth. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.


        And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.



        Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.



        documentclass{article}
        usepackage{enumitem}

        newcommand{parsedescription}[2]{%
        makebox[2.5cm][l]{#1}{#2}}

        begin{document}

        section{Hand rolled}

        This is a hand-rolled version
        begin{itemize}
        item Output of scanner:
        begin{enumerate}
        itemparsedescription{Identifier}{program}
        itemparsedescription{White_Space}{' '}
        end{enumerate}
        end{itemize}

        section{Properly done}

        And this is, much more semantically correct:

        newcounter{parsecounter}

        newlist{parse}{description}{1}
        setlist[parse]{style=sameline,
        labelwidth=3cm,
        leftmargin=!,
        labelindent=1em,
        font=normalfont,
        before={%
        setcounter{parsecounter}{0}%
        renewcommandmakelabel[1]{%
        stepcounter{parsecounter}%
        arabic{parsecounter}.enspace##1}}}


        begin{itemize}
        item Output of scanner:
        begin{parse}
        item[Identifier]program
        item[White_Space]' '
        end{parse}
        end{itemize}
        end{document}


        Output results






        share|improve this answer




























          1












          1








          1







          As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.



          Note also:




          • If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.

          • I can't approve of adding quads to put extra space after the item label. If the list is not as it should be, change labelsep and (if need be) labelwidth. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.


          And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.



          Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.



          documentclass{article}
          usepackage{enumitem}

          newcommand{parsedescription}[2]{%
          makebox[2.5cm][l]{#1}{#2}}

          begin{document}

          section{Hand rolled}

          This is a hand-rolled version
          begin{itemize}
          item Output of scanner:
          begin{enumerate}
          itemparsedescription{Identifier}{program}
          itemparsedescription{White_Space}{' '}
          end{enumerate}
          end{itemize}

          section{Properly done}

          And this is, much more semantically correct:

          newcounter{parsecounter}

          newlist{parse}{description}{1}
          setlist[parse]{style=sameline,
          labelwidth=3cm,
          leftmargin=!,
          labelindent=1em,
          font=normalfont,
          before={%
          setcounter{parsecounter}{0}%
          renewcommandmakelabel[1]{%
          stepcounter{parsecounter}%
          arabic{parsecounter}.enspace##1}}}


          begin{itemize}
          item Output of scanner:
          begin{parse}
          item[Identifier]program
          item[White_Space]' '
          end{parse}
          end{itemize}
          end{document}


          Output results






          share|improve this answer















          As Bubaya notes, one possibility is to put the "label" in a box of a fixed width, though I wouldn't "fiddle" with phantoms and the like. I've defined a command to do it. Further refinement (e.g. to automatically set the width to your longest label) would be desirable no doubt.



          Note also:




          • If you want an enumerated list, I'd ask for an enumerated list, not set the label by hand.

          • I can't approve of adding quads to put extra space after the item label. If the list is not as it should be, change labelsep and (if need be) labelwidth. Any time you are adding ad hoc spacing commands you are (probably) doing something wrong.


          And note finally: if this is being used for more than a single instance, I wouldn't do it. Do it properly. Set up a list-type: the thinking you have to do in setting it up repays itself again and again in ease of use and absence of error.



          Both alternatives demonstrated below. I'd obviously put the list definition in the preamble in production.



          documentclass{article}
          usepackage{enumitem}

          newcommand{parsedescription}[2]{%
          makebox[2.5cm][l]{#1}{#2}}

          begin{document}

          section{Hand rolled}

          This is a hand-rolled version
          begin{itemize}
          item Output of scanner:
          begin{enumerate}
          itemparsedescription{Identifier}{program}
          itemparsedescription{White_Space}{' '}
          end{enumerate}
          end{itemize}

          section{Properly done}

          And this is, much more semantically correct:

          newcounter{parsecounter}

          newlist{parse}{description}{1}
          setlist[parse]{style=sameline,
          labelwidth=3cm,
          leftmargin=!,
          labelindent=1em,
          font=normalfont,
          before={%
          setcounter{parsecounter}{0}%
          renewcommandmakelabel[1]{%
          stepcounter{parsecounter}%
          arabic{parsecounter}.enspace##1}}}


          begin{itemize}
          item Output of scanner:
          begin{parse}
          item[Identifier]program
          item[White_Space]' '
          end{parse}
          end{itemize}
          end{document}


          Output results







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 21 at 13:52

























          answered Feb 21 at 12:03









          Paul StanleyPaul Stanley

          14.8k42848




          14.8k42848























              1














              If using a table is not an option for you, you can always fiddle around manually with phantom or hphantom, makebox and widthof, of which the latter is provided by the calc package. So, to have your " underneath the word 'program', you can do:



              documentclass{article}
              usepackage{calc}
              begin{document}
              begin{enumerate}
              item makebox[widthof{White_Space}][l]{Identifier}quad program
              item White_Space quad makebox[widthof{program}]{''}
              end{enumerate}
              end{document}


              enter image description here



              However, if this is to be a lengthy list, consider using the tabular environment.






              share|improve this answer




























                1














                If using a table is not an option for you, you can always fiddle around manually with phantom or hphantom, makebox and widthof, of which the latter is provided by the calc package. So, to have your " underneath the word 'program', you can do:



                documentclass{article}
                usepackage{calc}
                begin{document}
                begin{enumerate}
                item makebox[widthof{White_Space}][l]{Identifier}quad program
                item White_Space quad makebox[widthof{program}]{''}
                end{enumerate}
                end{document}


                enter image description here



                However, if this is to be a lengthy list, consider using the tabular environment.






                share|improve this answer


























                  1












                  1








                  1







                  If using a table is not an option for you, you can always fiddle around manually with phantom or hphantom, makebox and widthof, of which the latter is provided by the calc package. So, to have your " underneath the word 'program', you can do:



                  documentclass{article}
                  usepackage{calc}
                  begin{document}
                  begin{enumerate}
                  item makebox[widthof{White_Space}][l]{Identifier}quad program
                  item White_Space quad makebox[widthof{program}]{''}
                  end{enumerate}
                  end{document}


                  enter image description here



                  However, if this is to be a lengthy list, consider using the tabular environment.






                  share|improve this answer













                  If using a table is not an option for you, you can always fiddle around manually with phantom or hphantom, makebox and widthof, of which the latter is provided by the calc package. So, to have your " underneath the word 'program', you can do:



                  documentclass{article}
                  usepackage{calc}
                  begin{document}
                  begin{enumerate}
                  item makebox[widthof{White_Space}][l]{Identifier}quad program
                  item White_Space quad makebox[widthof{program}]{''}
                  end{enumerate}
                  end{document}


                  enter image description here



                  However, if this is to be a lengthy list, consider using the tabular environment.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 21 at 10:54









                  BubayaBubaya

                  657310




                  657310






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f475969%2funeven-tab-for-align-text%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How to change which sound is reproduced for terminal bell?

                      Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                      Can I use Tabulator js library in my java Spring + Thymeleaf project?