Spacing between groups of two list items












5















I'm trying to format a homework document, in which I want to write the questions and answers in a list. The question is followed by an answer, after which I want a slightly bigger gap before the next question and answer



begin{itemize}
item[Q.] Question 1
item[A.] Answer 1
%space here
item[Q.] Question 2
item[A.] Answer 2
end{itemize}


Currently, I'm adding a space by using an empty list item (item). The output is shown below. Unfortunately, this creates a much larger space than I want. Is there a cleaner way to do this?



Output










share|improve this question























  • Welcome to TeX.SX! A hackish way would be to insert vspace{<some amount>} there. For example, vspace{0.25cm}. This would be quite boring for longer lists though...

    – Phelype Oleinik
    Sep 10 '18 at 22:48
















5















I'm trying to format a homework document, in which I want to write the questions and answers in a list. The question is followed by an answer, after which I want a slightly bigger gap before the next question and answer



begin{itemize}
item[Q.] Question 1
item[A.] Answer 1
%space here
item[Q.] Question 2
item[A.] Answer 2
end{itemize}


Currently, I'm adding a space by using an empty list item (item). The output is shown below. Unfortunately, this creates a much larger space than I want. Is there a cleaner way to do this?



Output










share|improve this question























  • Welcome to TeX.SX! A hackish way would be to insert vspace{<some amount>} there. For example, vspace{0.25cm}. This would be quite boring for longer lists though...

    – Phelype Oleinik
    Sep 10 '18 at 22:48














5












5








5








I'm trying to format a homework document, in which I want to write the questions and answers in a list. The question is followed by an answer, after which I want a slightly bigger gap before the next question and answer



begin{itemize}
item[Q.] Question 1
item[A.] Answer 1
%space here
item[Q.] Question 2
item[A.] Answer 2
end{itemize}


Currently, I'm adding a space by using an empty list item (item). The output is shown below. Unfortunately, this creates a much larger space than I want. Is there a cleaner way to do this?



Output










share|improve this question














I'm trying to format a homework document, in which I want to write the questions and answers in a list. The question is followed by an answer, after which I want a slightly bigger gap before the next question and answer



begin{itemize}
item[Q.] Question 1
item[A.] Answer 1
%space here
item[Q.] Question 2
item[A.] Answer 2
end{itemize}


Currently, I'm adding a space by using an empty list item (item). The output is shown below. Unfortunately, this creates a much larger space than I want. Is there a cleaner way to do this?



Output







formatting lists






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 10 '18 at 22:44









Abhijeet KrishnanAbhijeet Krishnan

262




262













  • Welcome to TeX.SX! A hackish way would be to insert vspace{<some amount>} there. For example, vspace{0.25cm}. This would be quite boring for longer lists though...

    – Phelype Oleinik
    Sep 10 '18 at 22:48



















  • Welcome to TeX.SX! A hackish way would be to insert vspace{<some amount>} there. For example, vspace{0.25cm}. This would be quite boring for longer lists though...

    – Phelype Oleinik
    Sep 10 '18 at 22:48

















Welcome to TeX.SX! A hackish way would be to insert vspace{<some amount>} there. For example, vspace{0.25cm}. This would be quite boring for longer lists though...

– Phelype Oleinik
Sep 10 '18 at 22:48





Welcome to TeX.SX! A hackish way would be to insert vspace{<some amount>} there. For example, vspace{0.25cm}. This would be quite boring for longer lists though...

– Phelype Oleinik
Sep 10 '18 at 22:48










5 Answers
5






active

oldest

votes


















5














Very basic solution which doesn't require manual spacing:



Define two macros, question and answer, which do item[Q.] and item[A.], respectively. The question macro also inserts a vertical space of 0.25 cm if it's not in the first question, so the space between the list and the paragraph is right.




enter image description here




documentclass{article}

usepackage{lipsum}% Just for dummy text

makeatletter
newififfirstquestion
firstquestiontrue
defquestion{%
iffirstquestion
firstquestionfalse
else
vspace{0.25cm}%
fi
item[Q.]}
defanswer{%
item[A.]}
makeatother

begin{document}

lipsum[1]

begin{itemize}
question Question 1
answer Answer 1
question Question 2
answer Answer 2
question Question 2
answer Answer 2
question Question 2
answer Answer 2
end{itemize}

lipsum[1]

end{document}


and, following A. Ellet's suggestion, if you will always label each item with "Question /Answer ", you can use a counter:



documentclass{article}

usepackage{lipsum}% Just for dummy text

makeatletter
newcounter{QuestionCounter}
newififfirstquestion
firstquestiontrue
defquestion{%
iffirstquestion
setcounter{QuestionCounter}{1}% Remove this to have the same numbering across different itemize's
firstquestionfalse
else
vspace{0.25cm}%
fi
item[Q.] Question theQuestionCounter:space}
defanswer{%
item[A.] Answer theQuestionCounter:space
stepcounter{QuestionCounter}}
makeatother

begin{document}

lipsum[1]

begin{itemize}
question What's your name?
answer Foo
question Where do you live?
answer Bar
question How old are you?
answer -1
end{itemize}

lipsum[1]

end{document}





share|improve this answer


























  • I would incorporate a counter, paircounter for each question/answer pair so that question expands to item[Q.] Question thepaircounter and answer expands to item[A.] Answer thepaircounter.

    – A.Ellett
    Sep 10 '18 at 23:13











  • @A.Ellett If the questions and answers will be labelled, then it's a good idea indeed. I added a version with that. Thanks :)

    – Phelype Oleinik
    Sep 10 '18 at 23:22



















3














You have several options.




  • The simplest is: Define your own command, say questionVSpace, to use a space between elements within a list. Observe that the definition of vertical space command may depend on the class you use.

  • There are more elaborate ways to do it. I recommend using a command for doing so. This command should handle the vertical space automatically and should handle layout issues globally, e.g. if you want to change "Q." to "Question". A crude but more useful way is my second variant. This also allows to enumerate the question, see my code below.


These variants are implemented in the following MWE.



documentclass{article} 

%you can manually choose a space here if you do not like the predefined ones
%In case you want to use one of the predfined ones, say smallskip, you should still use questionVSpace and replace vspace{9ex} with smallskip
newcommand{questionVSpace}{vspace{9ex}}


newcounter{questionCounter}
newcommand{qAndA}[2]{
%The following code automatically adds the space unless it is the first question.
ifnumvalue{questionCounter}>0
bigskip%you can choose a different space here.
fi
stepcounter{questionCounter}
% You could also change "Q." to "Q. thequestionCounter"
item[Q.] #1
item[A.] #2
}

begin{document}
section{Variant A}
Test
begin{itemize}
item[Q.] Question 1
item[A.] Answer 1
smallskip
item[Q.] Question 2
item[A.] Answer 2
medskip
item[Q.] Question 3
item[A.] Answer 3
bigskip
item[Q.] Question 4
item[A.] Answer 4
questionVSpace
item[Q.] Question 5
item[A.] Answer 5
end{itemize}

section{Variant B}
Test
begin{itemize}
qAndA {Text foo}{Text bar}
qAndA {Text foo}{Text bar}
qAndA {Text foo}{Text bar}
end{itemize}
end{document}


enter image description here






share|improve this answer





















  • 1





    I think you forgot something at ifthequestionCounter. This will always evaluate to false. See the extra vertical space between 0.2 B and Q. Text foo.

    – Phelype Oleinik
    Sep 10 '18 at 23:14











  • @PhelypeOleinik Than you very much. I hope it is fixed now.

    – CampanIgnis
    Sep 10 '18 at 23:24





















2














More simply, you could use a different itemize for each Q & A:



begin{itemize}
item[Q.] Question 1
item[A.] Answer 1
end[itemize}

begin{itemize}
item[Q.] Question 2
item[A.] Answer 2
end{itemize}





share|improve this answer































    1














    Here's an approach using a new environment called QA. I've tried to throw in enough to let you see what's possible beyond just what you asked and to allow you to see where additional tweaks might enhance what you're doing. I've exaggerated the effect of adding vertical space between an answer and a following question: tweak to something more suitable.



    documentclass{article}

    newcounter{aeQAcounter}
    newcounter{aePAIRcounter}
    defaeRememberLastPair{1}
    newenvironment{QA}[1]
    {%% save the definition of `item` so I can access
    %% its definition later when I *redefine* it.
    letaeitemitem
    %% a crude key value'ish approach to remembering
    %% previous value for question/answer pair.
    defaeTestA{#1}%%
    defaeTestB{remember previous}%%
    ifxaeTestAaeTestB
    %% nothing to do here!!
    else
    defaeRememberLastPair{1}%%
    fi
    setcounter{aePAIRcounter}{aeRememberLastPair}%%
    begin{list}{%%
    sffamily
    ifoddtheaeQAcounter Question theaePAIRcounter%%
    else
    Answer theaePAIRcounter%%
    stepcounter{aePAIRcounter}%%
    fi
    :%%
    }
    {usecounter{aeQAcounter}}%%
    defitem{%%
    %% only add space if not the first question
    ifnumtheaePAIRcounter=aeRememberLastPair
    %% do nothing!!!!
    else
    %% only add space before question and after
    %% an answer (the even `item` in the list)
    ifoddtheaeQAcounter
    else
    vspace{4ex}%%
    fi
    fi
    aeitem}
    letquestionitem
    letansweritem
    }
    {xdefaeRememberLastPair{theaePAIRcounter}%%
    end{list}}

    begin{document}

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
    purus elit, vestibulum ut, placerat ac, adipiscing vitae,
    felis. Curabitur dictum gravida mauris. Nam arcu
    begin{QA}
    question What do you say when you part from someone?
    question bye
    question What is a fruit that shouldn't be mixed with apples?
    answer An orange.
    end{QA}
    Nam dui ligula, fringilla a, euismod sodales, sollicitudin
    vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
    pretium at, lobortis vitae, ultricies et.
    textbf{sffamily And, we continue with more questions:}
    begin{QA}[remember previous]
    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
    end{QA}

    textbf{sffamily And, Here is a new set of questions:}
    begin{QA}
    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
    end{QA}


    end{document}


    enter image description here



    Notice that I use two counters here. One counter is essentially the list's counter for each item. If it's odd, that means I'm asking a question. If it's even, that means I'm answering a question. The second counter is only advanced once the question/answer pair has been established.



    Also, notice that question and answer are stupid, in the sense that they're really just stand-ins for item and don't do much else. Everything is handled through item and tracking counters. I try to let the environment itself handle the tracking of questions and answers. The only difficulty comes when adding space. From within the {list} environment's arguments, not much can be done.



    One thing to note, you cannot insert vspace{...} from within the first argument to the {list} environment. It will do nothing there and just be ignored for the most part (or show up where you don't expect it).






    share|improve this answer

































      1














      The space between items is controlled by itemsep, so you can fix for each item, with the advantage that your Q & A lists will not influenced by the default itemsep as it would happen using some additional vertical space as vspace,bigskip. I will add some glue too, not a fixed length, that would help to avoid orphan items/lines.



      This can be done easily as already proposed making a macro for each item type, and I think that semantically is better that a complex redefine of item type to hiddenly switch from "Q." to "A.". With the "keep it simple" principle in mind, I do not see the need of conditionals or counters (I will edit the answer if you clarify this point), so the macros could be some like this:



      documentclass{article}

      newcommandQ[1]{item[bfseries Q.]
      itemsep2pt plus 2pt #1}
      newcommandA[1]{item[bfseries A.]
      itemsep1em plus .2em minus .1em #1}

      newenvironment{q-a}{section*{Questions
      and answers}begin{itemize}}{end{itemize}}

      begin{document}

      begin{q-a}
      Q Question 1
      A Answer 1
      Q Question 2
      A Answer 2
      Q Question 3
      A Answer 3
      end{q-a}

      end{document}


      mwe






      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%2f450319%2fspacing-between-groups-of-two-list-items%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        5 Answers
        5






        active

        oldest

        votes








        5 Answers
        5






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        5














        Very basic solution which doesn't require manual spacing:



        Define two macros, question and answer, which do item[Q.] and item[A.], respectively. The question macro also inserts a vertical space of 0.25 cm if it's not in the first question, so the space between the list and the paragraph is right.




        enter image description here




        documentclass{article}

        usepackage{lipsum}% Just for dummy text

        makeatletter
        newififfirstquestion
        firstquestiontrue
        defquestion{%
        iffirstquestion
        firstquestionfalse
        else
        vspace{0.25cm}%
        fi
        item[Q.]}
        defanswer{%
        item[A.]}
        makeatother

        begin{document}

        lipsum[1]

        begin{itemize}
        question Question 1
        answer Answer 1
        question Question 2
        answer Answer 2
        question Question 2
        answer Answer 2
        question Question 2
        answer Answer 2
        end{itemize}

        lipsum[1]

        end{document}


        and, following A. Ellet's suggestion, if you will always label each item with "Question /Answer ", you can use a counter:



        documentclass{article}

        usepackage{lipsum}% Just for dummy text

        makeatletter
        newcounter{QuestionCounter}
        newififfirstquestion
        firstquestiontrue
        defquestion{%
        iffirstquestion
        setcounter{QuestionCounter}{1}% Remove this to have the same numbering across different itemize's
        firstquestionfalse
        else
        vspace{0.25cm}%
        fi
        item[Q.] Question theQuestionCounter:space}
        defanswer{%
        item[A.] Answer theQuestionCounter:space
        stepcounter{QuestionCounter}}
        makeatother

        begin{document}

        lipsum[1]

        begin{itemize}
        question What's your name?
        answer Foo
        question Where do you live?
        answer Bar
        question How old are you?
        answer -1
        end{itemize}

        lipsum[1]

        end{document}





        share|improve this answer


























        • I would incorporate a counter, paircounter for each question/answer pair so that question expands to item[Q.] Question thepaircounter and answer expands to item[A.] Answer thepaircounter.

          – A.Ellett
          Sep 10 '18 at 23:13











        • @A.Ellett If the questions and answers will be labelled, then it's a good idea indeed. I added a version with that. Thanks :)

          – Phelype Oleinik
          Sep 10 '18 at 23:22
















        5














        Very basic solution which doesn't require manual spacing:



        Define two macros, question and answer, which do item[Q.] and item[A.], respectively. The question macro also inserts a vertical space of 0.25 cm if it's not in the first question, so the space between the list and the paragraph is right.




        enter image description here




        documentclass{article}

        usepackage{lipsum}% Just for dummy text

        makeatletter
        newififfirstquestion
        firstquestiontrue
        defquestion{%
        iffirstquestion
        firstquestionfalse
        else
        vspace{0.25cm}%
        fi
        item[Q.]}
        defanswer{%
        item[A.]}
        makeatother

        begin{document}

        lipsum[1]

        begin{itemize}
        question Question 1
        answer Answer 1
        question Question 2
        answer Answer 2
        question Question 2
        answer Answer 2
        question Question 2
        answer Answer 2
        end{itemize}

        lipsum[1]

        end{document}


        and, following A. Ellet's suggestion, if you will always label each item with "Question /Answer ", you can use a counter:



        documentclass{article}

        usepackage{lipsum}% Just for dummy text

        makeatletter
        newcounter{QuestionCounter}
        newififfirstquestion
        firstquestiontrue
        defquestion{%
        iffirstquestion
        setcounter{QuestionCounter}{1}% Remove this to have the same numbering across different itemize's
        firstquestionfalse
        else
        vspace{0.25cm}%
        fi
        item[Q.] Question theQuestionCounter:space}
        defanswer{%
        item[A.] Answer theQuestionCounter:space
        stepcounter{QuestionCounter}}
        makeatother

        begin{document}

        lipsum[1]

        begin{itemize}
        question What's your name?
        answer Foo
        question Where do you live?
        answer Bar
        question How old are you?
        answer -1
        end{itemize}

        lipsum[1]

        end{document}





        share|improve this answer


























        • I would incorporate a counter, paircounter for each question/answer pair so that question expands to item[Q.] Question thepaircounter and answer expands to item[A.] Answer thepaircounter.

          – A.Ellett
          Sep 10 '18 at 23:13











        • @A.Ellett If the questions and answers will be labelled, then it's a good idea indeed. I added a version with that. Thanks :)

          – Phelype Oleinik
          Sep 10 '18 at 23:22














        5












        5








        5







        Very basic solution which doesn't require manual spacing:



        Define two macros, question and answer, which do item[Q.] and item[A.], respectively. The question macro also inserts a vertical space of 0.25 cm if it's not in the first question, so the space between the list and the paragraph is right.




        enter image description here




        documentclass{article}

        usepackage{lipsum}% Just for dummy text

        makeatletter
        newififfirstquestion
        firstquestiontrue
        defquestion{%
        iffirstquestion
        firstquestionfalse
        else
        vspace{0.25cm}%
        fi
        item[Q.]}
        defanswer{%
        item[A.]}
        makeatother

        begin{document}

        lipsum[1]

        begin{itemize}
        question Question 1
        answer Answer 1
        question Question 2
        answer Answer 2
        question Question 2
        answer Answer 2
        question Question 2
        answer Answer 2
        end{itemize}

        lipsum[1]

        end{document}


        and, following A. Ellet's suggestion, if you will always label each item with "Question /Answer ", you can use a counter:



        documentclass{article}

        usepackage{lipsum}% Just for dummy text

        makeatletter
        newcounter{QuestionCounter}
        newififfirstquestion
        firstquestiontrue
        defquestion{%
        iffirstquestion
        setcounter{QuestionCounter}{1}% Remove this to have the same numbering across different itemize's
        firstquestionfalse
        else
        vspace{0.25cm}%
        fi
        item[Q.] Question theQuestionCounter:space}
        defanswer{%
        item[A.] Answer theQuestionCounter:space
        stepcounter{QuestionCounter}}
        makeatother

        begin{document}

        lipsum[1]

        begin{itemize}
        question What's your name?
        answer Foo
        question Where do you live?
        answer Bar
        question How old are you?
        answer -1
        end{itemize}

        lipsum[1]

        end{document}





        share|improve this answer















        Very basic solution which doesn't require manual spacing:



        Define two macros, question and answer, which do item[Q.] and item[A.], respectively. The question macro also inserts a vertical space of 0.25 cm if it's not in the first question, so the space between the list and the paragraph is right.




        enter image description here




        documentclass{article}

        usepackage{lipsum}% Just for dummy text

        makeatletter
        newififfirstquestion
        firstquestiontrue
        defquestion{%
        iffirstquestion
        firstquestionfalse
        else
        vspace{0.25cm}%
        fi
        item[Q.]}
        defanswer{%
        item[A.]}
        makeatother

        begin{document}

        lipsum[1]

        begin{itemize}
        question Question 1
        answer Answer 1
        question Question 2
        answer Answer 2
        question Question 2
        answer Answer 2
        question Question 2
        answer Answer 2
        end{itemize}

        lipsum[1]

        end{document}


        and, following A. Ellet's suggestion, if you will always label each item with "Question /Answer ", you can use a counter:



        documentclass{article}

        usepackage{lipsum}% Just for dummy text

        makeatletter
        newcounter{QuestionCounter}
        newififfirstquestion
        firstquestiontrue
        defquestion{%
        iffirstquestion
        setcounter{QuestionCounter}{1}% Remove this to have the same numbering across different itemize's
        firstquestionfalse
        else
        vspace{0.25cm}%
        fi
        item[Q.] Question theQuestionCounter:space}
        defanswer{%
        item[A.] Answer theQuestionCounter:space
        stepcounter{QuestionCounter}}
        makeatother

        begin{document}

        lipsum[1]

        begin{itemize}
        question What's your name?
        answer Foo
        question Where do you live?
        answer Bar
        question How old are you?
        answer -1
        end{itemize}

        lipsum[1]

        end{document}






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 18 at 19:50

























        answered Sep 10 '18 at 22:56









        Phelype OleinikPhelype Oleinik

        24.6k54688




        24.6k54688













        • I would incorporate a counter, paircounter for each question/answer pair so that question expands to item[Q.] Question thepaircounter and answer expands to item[A.] Answer thepaircounter.

          – A.Ellett
          Sep 10 '18 at 23:13











        • @A.Ellett If the questions and answers will be labelled, then it's a good idea indeed. I added a version with that. Thanks :)

          – Phelype Oleinik
          Sep 10 '18 at 23:22



















        • I would incorporate a counter, paircounter for each question/answer pair so that question expands to item[Q.] Question thepaircounter and answer expands to item[A.] Answer thepaircounter.

          – A.Ellett
          Sep 10 '18 at 23:13











        • @A.Ellett If the questions and answers will be labelled, then it's a good idea indeed. I added a version with that. Thanks :)

          – Phelype Oleinik
          Sep 10 '18 at 23:22

















        I would incorporate a counter, paircounter for each question/answer pair so that question expands to item[Q.] Question thepaircounter and answer expands to item[A.] Answer thepaircounter.

        – A.Ellett
        Sep 10 '18 at 23:13





        I would incorporate a counter, paircounter for each question/answer pair so that question expands to item[Q.] Question thepaircounter and answer expands to item[A.] Answer thepaircounter.

        – A.Ellett
        Sep 10 '18 at 23:13













        @A.Ellett If the questions and answers will be labelled, then it's a good idea indeed. I added a version with that. Thanks :)

        – Phelype Oleinik
        Sep 10 '18 at 23:22





        @A.Ellett If the questions and answers will be labelled, then it's a good idea indeed. I added a version with that. Thanks :)

        – Phelype Oleinik
        Sep 10 '18 at 23:22











        3














        You have several options.




        • The simplest is: Define your own command, say questionVSpace, to use a space between elements within a list. Observe that the definition of vertical space command may depend on the class you use.

        • There are more elaborate ways to do it. I recommend using a command for doing so. This command should handle the vertical space automatically and should handle layout issues globally, e.g. if you want to change "Q." to "Question". A crude but more useful way is my second variant. This also allows to enumerate the question, see my code below.


        These variants are implemented in the following MWE.



        documentclass{article} 

        %you can manually choose a space here if you do not like the predefined ones
        %In case you want to use one of the predfined ones, say smallskip, you should still use questionVSpace and replace vspace{9ex} with smallskip
        newcommand{questionVSpace}{vspace{9ex}}


        newcounter{questionCounter}
        newcommand{qAndA}[2]{
        %The following code automatically adds the space unless it is the first question.
        ifnumvalue{questionCounter}>0
        bigskip%you can choose a different space here.
        fi
        stepcounter{questionCounter}
        % You could also change "Q." to "Q. thequestionCounter"
        item[Q.] #1
        item[A.] #2
        }

        begin{document}
        section{Variant A}
        Test
        begin{itemize}
        item[Q.] Question 1
        item[A.] Answer 1
        smallskip
        item[Q.] Question 2
        item[A.] Answer 2
        medskip
        item[Q.] Question 3
        item[A.] Answer 3
        bigskip
        item[Q.] Question 4
        item[A.] Answer 4
        questionVSpace
        item[Q.] Question 5
        item[A.] Answer 5
        end{itemize}

        section{Variant B}
        Test
        begin{itemize}
        qAndA {Text foo}{Text bar}
        qAndA {Text foo}{Text bar}
        qAndA {Text foo}{Text bar}
        end{itemize}
        end{document}


        enter image description here






        share|improve this answer





















        • 1





          I think you forgot something at ifthequestionCounter. This will always evaluate to false. See the extra vertical space between 0.2 B and Q. Text foo.

          – Phelype Oleinik
          Sep 10 '18 at 23:14











        • @PhelypeOleinik Than you very much. I hope it is fixed now.

          – CampanIgnis
          Sep 10 '18 at 23:24


















        3














        You have several options.




        • The simplest is: Define your own command, say questionVSpace, to use a space between elements within a list. Observe that the definition of vertical space command may depend on the class you use.

        • There are more elaborate ways to do it. I recommend using a command for doing so. This command should handle the vertical space automatically and should handle layout issues globally, e.g. if you want to change "Q." to "Question". A crude but more useful way is my second variant. This also allows to enumerate the question, see my code below.


        These variants are implemented in the following MWE.



        documentclass{article} 

        %you can manually choose a space here if you do not like the predefined ones
        %In case you want to use one of the predfined ones, say smallskip, you should still use questionVSpace and replace vspace{9ex} with smallskip
        newcommand{questionVSpace}{vspace{9ex}}


        newcounter{questionCounter}
        newcommand{qAndA}[2]{
        %The following code automatically adds the space unless it is the first question.
        ifnumvalue{questionCounter}>0
        bigskip%you can choose a different space here.
        fi
        stepcounter{questionCounter}
        % You could also change "Q." to "Q. thequestionCounter"
        item[Q.] #1
        item[A.] #2
        }

        begin{document}
        section{Variant A}
        Test
        begin{itemize}
        item[Q.] Question 1
        item[A.] Answer 1
        smallskip
        item[Q.] Question 2
        item[A.] Answer 2
        medskip
        item[Q.] Question 3
        item[A.] Answer 3
        bigskip
        item[Q.] Question 4
        item[A.] Answer 4
        questionVSpace
        item[Q.] Question 5
        item[A.] Answer 5
        end{itemize}

        section{Variant B}
        Test
        begin{itemize}
        qAndA {Text foo}{Text bar}
        qAndA {Text foo}{Text bar}
        qAndA {Text foo}{Text bar}
        end{itemize}
        end{document}


        enter image description here






        share|improve this answer





















        • 1





          I think you forgot something at ifthequestionCounter. This will always evaluate to false. See the extra vertical space between 0.2 B and Q. Text foo.

          – Phelype Oleinik
          Sep 10 '18 at 23:14











        • @PhelypeOleinik Than you very much. I hope it is fixed now.

          – CampanIgnis
          Sep 10 '18 at 23:24
















        3












        3








        3







        You have several options.




        • The simplest is: Define your own command, say questionVSpace, to use a space between elements within a list. Observe that the definition of vertical space command may depend on the class you use.

        • There are more elaborate ways to do it. I recommend using a command for doing so. This command should handle the vertical space automatically and should handle layout issues globally, e.g. if you want to change "Q." to "Question". A crude but more useful way is my second variant. This also allows to enumerate the question, see my code below.


        These variants are implemented in the following MWE.



        documentclass{article} 

        %you can manually choose a space here if you do not like the predefined ones
        %In case you want to use one of the predfined ones, say smallskip, you should still use questionVSpace and replace vspace{9ex} with smallskip
        newcommand{questionVSpace}{vspace{9ex}}


        newcounter{questionCounter}
        newcommand{qAndA}[2]{
        %The following code automatically adds the space unless it is the first question.
        ifnumvalue{questionCounter}>0
        bigskip%you can choose a different space here.
        fi
        stepcounter{questionCounter}
        % You could also change "Q." to "Q. thequestionCounter"
        item[Q.] #1
        item[A.] #2
        }

        begin{document}
        section{Variant A}
        Test
        begin{itemize}
        item[Q.] Question 1
        item[A.] Answer 1
        smallskip
        item[Q.] Question 2
        item[A.] Answer 2
        medskip
        item[Q.] Question 3
        item[A.] Answer 3
        bigskip
        item[Q.] Question 4
        item[A.] Answer 4
        questionVSpace
        item[Q.] Question 5
        item[A.] Answer 5
        end{itemize}

        section{Variant B}
        Test
        begin{itemize}
        qAndA {Text foo}{Text bar}
        qAndA {Text foo}{Text bar}
        qAndA {Text foo}{Text bar}
        end{itemize}
        end{document}


        enter image description here






        share|improve this answer















        You have several options.




        • The simplest is: Define your own command, say questionVSpace, to use a space between elements within a list. Observe that the definition of vertical space command may depend on the class you use.

        • There are more elaborate ways to do it. I recommend using a command for doing so. This command should handle the vertical space automatically and should handle layout issues globally, e.g. if you want to change "Q." to "Question". A crude but more useful way is my second variant. This also allows to enumerate the question, see my code below.


        These variants are implemented in the following MWE.



        documentclass{article} 

        %you can manually choose a space here if you do not like the predefined ones
        %In case you want to use one of the predfined ones, say smallskip, you should still use questionVSpace and replace vspace{9ex} with smallskip
        newcommand{questionVSpace}{vspace{9ex}}


        newcounter{questionCounter}
        newcommand{qAndA}[2]{
        %The following code automatically adds the space unless it is the first question.
        ifnumvalue{questionCounter}>0
        bigskip%you can choose a different space here.
        fi
        stepcounter{questionCounter}
        % You could also change "Q." to "Q. thequestionCounter"
        item[Q.] #1
        item[A.] #2
        }

        begin{document}
        section{Variant A}
        Test
        begin{itemize}
        item[Q.] Question 1
        item[A.] Answer 1
        smallskip
        item[Q.] Question 2
        item[A.] Answer 2
        medskip
        item[Q.] Question 3
        item[A.] Answer 3
        bigskip
        item[Q.] Question 4
        item[A.] Answer 4
        questionVSpace
        item[Q.] Question 5
        item[A.] Answer 5
        end{itemize}

        section{Variant B}
        Test
        begin{itemize}
        qAndA {Text foo}{Text bar}
        qAndA {Text foo}{Text bar}
        qAndA {Text foo}{Text bar}
        end{itemize}
        end{document}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 11 '18 at 10:55

























        answered Sep 10 '18 at 22:51









        CampanIgnisCampanIgnis

        3,03921034




        3,03921034








        • 1





          I think you forgot something at ifthequestionCounter. This will always evaluate to false. See the extra vertical space between 0.2 B and Q. Text foo.

          – Phelype Oleinik
          Sep 10 '18 at 23:14











        • @PhelypeOleinik Than you very much. I hope it is fixed now.

          – CampanIgnis
          Sep 10 '18 at 23:24
















        • 1





          I think you forgot something at ifthequestionCounter. This will always evaluate to false. See the extra vertical space between 0.2 B and Q. Text foo.

          – Phelype Oleinik
          Sep 10 '18 at 23:14











        • @PhelypeOleinik Than you very much. I hope it is fixed now.

          – CampanIgnis
          Sep 10 '18 at 23:24










        1




        1





        I think you forgot something at ifthequestionCounter. This will always evaluate to false. See the extra vertical space between 0.2 B and Q. Text foo.

        – Phelype Oleinik
        Sep 10 '18 at 23:14





        I think you forgot something at ifthequestionCounter. This will always evaluate to false. See the extra vertical space between 0.2 B and Q. Text foo.

        – Phelype Oleinik
        Sep 10 '18 at 23:14













        @PhelypeOleinik Than you very much. I hope it is fixed now.

        – CampanIgnis
        Sep 10 '18 at 23:24







        @PhelypeOleinik Than you very much. I hope it is fixed now.

        – CampanIgnis
        Sep 10 '18 at 23:24













        2














        More simply, you could use a different itemize for each Q & A:



        begin{itemize}
        item[Q.] Question 1
        item[A.] Answer 1
        end[itemize}

        begin{itemize}
        item[Q.] Question 2
        item[A.] Answer 2
        end{itemize}





        share|improve this answer




























          2














          More simply, you could use a different itemize for each Q & A:



          begin{itemize}
          item[Q.] Question 1
          item[A.] Answer 1
          end[itemize}

          begin{itemize}
          item[Q.] Question 2
          item[A.] Answer 2
          end{itemize}





          share|improve this answer


























            2












            2








            2







            More simply, you could use a different itemize for each Q & A:



            begin{itemize}
            item[Q.] Question 1
            item[A.] Answer 1
            end[itemize}

            begin{itemize}
            item[Q.] Question 2
            item[A.] Answer 2
            end{itemize}





            share|improve this answer













            More simply, you could use a different itemize for each Q & A:



            begin{itemize}
            item[Q.] Question 1
            item[A.] Answer 1
            end[itemize}

            begin{itemize}
            item[Q.] Question 2
            item[A.] Answer 2
            end{itemize}






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 11 '18 at 1:41









            user94293user94293

            2,184616




            2,184616























                1














                Here's an approach using a new environment called QA. I've tried to throw in enough to let you see what's possible beyond just what you asked and to allow you to see where additional tweaks might enhance what you're doing. I've exaggerated the effect of adding vertical space between an answer and a following question: tweak to something more suitable.



                documentclass{article}

                newcounter{aeQAcounter}
                newcounter{aePAIRcounter}
                defaeRememberLastPair{1}
                newenvironment{QA}[1]
                {%% save the definition of `item` so I can access
                %% its definition later when I *redefine* it.
                letaeitemitem
                %% a crude key value'ish approach to remembering
                %% previous value for question/answer pair.
                defaeTestA{#1}%%
                defaeTestB{remember previous}%%
                ifxaeTestAaeTestB
                %% nothing to do here!!
                else
                defaeRememberLastPair{1}%%
                fi
                setcounter{aePAIRcounter}{aeRememberLastPair}%%
                begin{list}{%%
                sffamily
                ifoddtheaeQAcounter Question theaePAIRcounter%%
                else
                Answer theaePAIRcounter%%
                stepcounter{aePAIRcounter}%%
                fi
                :%%
                }
                {usecounter{aeQAcounter}}%%
                defitem{%%
                %% only add space if not the first question
                ifnumtheaePAIRcounter=aeRememberLastPair
                %% do nothing!!!!
                else
                %% only add space before question and after
                %% an answer (the even `item` in the list)
                ifoddtheaeQAcounter
                else
                vspace{4ex}%%
                fi
                fi
                aeitem}
                letquestionitem
                letansweritem
                }
                {xdefaeRememberLastPair{theaePAIRcounter}%%
                end{list}}

                begin{document}

                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
                purus elit, vestibulum ut, placerat ac, adipiscing vitae,
                felis. Curabitur dictum gravida mauris. Nam arcu
                begin{QA}
                question What do you say when you part from someone?
                question bye
                question What is a fruit that shouldn't be mixed with apples?
                answer An orange.
                end{QA}
                Nam dui ligula, fringilla a, euismod sodales, sollicitudin
                vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
                pretium at, lobortis vitae, ultricies et.
                textbf{sffamily And, we continue with more questions:}
                begin{QA}[remember previous]
                question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                end{QA}

                textbf{sffamily And, Here is a new set of questions:}
                begin{QA}
                question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                end{QA}


                end{document}


                enter image description here



                Notice that I use two counters here. One counter is essentially the list's counter for each item. If it's odd, that means I'm asking a question. If it's even, that means I'm answering a question. The second counter is only advanced once the question/answer pair has been established.



                Also, notice that question and answer are stupid, in the sense that they're really just stand-ins for item and don't do much else. Everything is handled through item and tracking counters. I try to let the environment itself handle the tracking of questions and answers. The only difficulty comes when adding space. From within the {list} environment's arguments, not much can be done.



                One thing to note, you cannot insert vspace{...} from within the first argument to the {list} environment. It will do nothing there and just be ignored for the most part (or show up where you don't expect it).






                share|improve this answer






























                  1














                  Here's an approach using a new environment called QA. I've tried to throw in enough to let you see what's possible beyond just what you asked and to allow you to see where additional tweaks might enhance what you're doing. I've exaggerated the effect of adding vertical space between an answer and a following question: tweak to something more suitable.



                  documentclass{article}

                  newcounter{aeQAcounter}
                  newcounter{aePAIRcounter}
                  defaeRememberLastPair{1}
                  newenvironment{QA}[1]
                  {%% save the definition of `item` so I can access
                  %% its definition later when I *redefine* it.
                  letaeitemitem
                  %% a crude key value'ish approach to remembering
                  %% previous value for question/answer pair.
                  defaeTestA{#1}%%
                  defaeTestB{remember previous}%%
                  ifxaeTestAaeTestB
                  %% nothing to do here!!
                  else
                  defaeRememberLastPair{1}%%
                  fi
                  setcounter{aePAIRcounter}{aeRememberLastPair}%%
                  begin{list}{%%
                  sffamily
                  ifoddtheaeQAcounter Question theaePAIRcounter%%
                  else
                  Answer theaePAIRcounter%%
                  stepcounter{aePAIRcounter}%%
                  fi
                  :%%
                  }
                  {usecounter{aeQAcounter}}%%
                  defitem{%%
                  %% only add space if not the first question
                  ifnumtheaePAIRcounter=aeRememberLastPair
                  %% do nothing!!!!
                  else
                  %% only add space before question and after
                  %% an answer (the even `item` in the list)
                  ifoddtheaeQAcounter
                  else
                  vspace{4ex}%%
                  fi
                  fi
                  aeitem}
                  letquestionitem
                  letansweritem
                  }
                  {xdefaeRememberLastPair{theaePAIRcounter}%%
                  end{list}}

                  begin{document}

                  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
                  purus elit, vestibulum ut, placerat ac, adipiscing vitae,
                  felis. Curabitur dictum gravida mauris. Nam arcu
                  begin{QA}
                  question What do you say when you part from someone?
                  question bye
                  question What is a fruit that shouldn't be mixed with apples?
                  answer An orange.
                  end{QA}
                  Nam dui ligula, fringilla a, euismod sodales, sollicitudin
                  vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
                  pretium at, lobortis vitae, ultricies et.
                  textbf{sffamily And, we continue with more questions:}
                  begin{QA}[remember previous]
                  question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                  answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                  question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                  answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                  end{QA}

                  textbf{sffamily And, Here is a new set of questions:}
                  begin{QA}
                  question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                  answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                  question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                  answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                  end{QA}


                  end{document}


                  enter image description here



                  Notice that I use two counters here. One counter is essentially the list's counter for each item. If it's odd, that means I'm asking a question. If it's even, that means I'm answering a question. The second counter is only advanced once the question/answer pair has been established.



                  Also, notice that question and answer are stupid, in the sense that they're really just stand-ins for item and don't do much else. Everything is handled through item and tracking counters. I try to let the environment itself handle the tracking of questions and answers. The only difficulty comes when adding space. From within the {list} environment's arguments, not much can be done.



                  One thing to note, you cannot insert vspace{...} from within the first argument to the {list} environment. It will do nothing there and just be ignored for the most part (or show up where you don't expect it).






                  share|improve this answer




























                    1












                    1








                    1







                    Here's an approach using a new environment called QA. I've tried to throw in enough to let you see what's possible beyond just what you asked and to allow you to see where additional tweaks might enhance what you're doing. I've exaggerated the effect of adding vertical space between an answer and a following question: tweak to something more suitable.



                    documentclass{article}

                    newcounter{aeQAcounter}
                    newcounter{aePAIRcounter}
                    defaeRememberLastPair{1}
                    newenvironment{QA}[1]
                    {%% save the definition of `item` so I can access
                    %% its definition later when I *redefine* it.
                    letaeitemitem
                    %% a crude key value'ish approach to remembering
                    %% previous value for question/answer pair.
                    defaeTestA{#1}%%
                    defaeTestB{remember previous}%%
                    ifxaeTestAaeTestB
                    %% nothing to do here!!
                    else
                    defaeRememberLastPair{1}%%
                    fi
                    setcounter{aePAIRcounter}{aeRememberLastPair}%%
                    begin{list}{%%
                    sffamily
                    ifoddtheaeQAcounter Question theaePAIRcounter%%
                    else
                    Answer theaePAIRcounter%%
                    stepcounter{aePAIRcounter}%%
                    fi
                    :%%
                    }
                    {usecounter{aeQAcounter}}%%
                    defitem{%%
                    %% only add space if not the first question
                    ifnumtheaePAIRcounter=aeRememberLastPair
                    %% do nothing!!!!
                    else
                    %% only add space before question and after
                    %% an answer (the even `item` in the list)
                    ifoddtheaeQAcounter
                    else
                    vspace{4ex}%%
                    fi
                    fi
                    aeitem}
                    letquestionitem
                    letansweritem
                    }
                    {xdefaeRememberLastPair{theaePAIRcounter}%%
                    end{list}}

                    begin{document}

                    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
                    purus elit, vestibulum ut, placerat ac, adipiscing vitae,
                    felis. Curabitur dictum gravida mauris. Nam arcu
                    begin{QA}
                    question What do you say when you part from someone?
                    question bye
                    question What is a fruit that shouldn't be mixed with apples?
                    answer An orange.
                    end{QA}
                    Nam dui ligula, fringilla a, euismod sodales, sollicitudin
                    vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
                    pretium at, lobortis vitae, ultricies et.
                    textbf{sffamily And, we continue with more questions:}
                    begin{QA}[remember previous]
                    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                    end{QA}

                    textbf{sffamily And, Here is a new set of questions:}
                    begin{QA}
                    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                    end{QA}


                    end{document}


                    enter image description here



                    Notice that I use two counters here. One counter is essentially the list's counter for each item. If it's odd, that means I'm asking a question. If it's even, that means I'm answering a question. The second counter is only advanced once the question/answer pair has been established.



                    Also, notice that question and answer are stupid, in the sense that they're really just stand-ins for item and don't do much else. Everything is handled through item and tracking counters. I try to let the environment itself handle the tracking of questions and answers. The only difficulty comes when adding space. From within the {list} environment's arguments, not much can be done.



                    One thing to note, you cannot insert vspace{...} from within the first argument to the {list} environment. It will do nothing there and just be ignored for the most part (or show up where you don't expect it).






                    share|improve this answer















                    Here's an approach using a new environment called QA. I've tried to throw in enough to let you see what's possible beyond just what you asked and to allow you to see where additional tweaks might enhance what you're doing. I've exaggerated the effect of adding vertical space between an answer and a following question: tweak to something more suitable.



                    documentclass{article}

                    newcounter{aeQAcounter}
                    newcounter{aePAIRcounter}
                    defaeRememberLastPair{1}
                    newenvironment{QA}[1]
                    {%% save the definition of `item` so I can access
                    %% its definition later when I *redefine* it.
                    letaeitemitem
                    %% a crude key value'ish approach to remembering
                    %% previous value for question/answer pair.
                    defaeTestA{#1}%%
                    defaeTestB{remember previous}%%
                    ifxaeTestAaeTestB
                    %% nothing to do here!!
                    else
                    defaeRememberLastPair{1}%%
                    fi
                    setcounter{aePAIRcounter}{aeRememberLastPair}%%
                    begin{list}{%%
                    sffamily
                    ifoddtheaeQAcounter Question theaePAIRcounter%%
                    else
                    Answer theaePAIRcounter%%
                    stepcounter{aePAIRcounter}%%
                    fi
                    :%%
                    }
                    {usecounter{aeQAcounter}}%%
                    defitem{%%
                    %% only add space if not the first question
                    ifnumtheaePAIRcounter=aeRememberLastPair
                    %% do nothing!!!!
                    else
                    %% only add space before question and after
                    %% an answer (the even `item` in the list)
                    ifoddtheaeQAcounter
                    else
                    vspace{4ex}%%
                    fi
                    fi
                    aeitem}
                    letquestionitem
                    letansweritem
                    }
                    {xdefaeRememberLastPair{theaePAIRcounter}%%
                    end{list}}

                    begin{document}

                    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
                    purus elit, vestibulum ut, placerat ac, adipiscing vitae,
                    felis. Curabitur dictum gravida mauris. Nam arcu
                    begin{QA}
                    question What do you say when you part from someone?
                    question bye
                    question What is a fruit that shouldn't be mixed with apples?
                    answer An orange.
                    end{QA}
                    Nam dui ligula, fringilla a, euismod sodales, sollicitudin
                    vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
                    pretium at, lobortis vitae, ultricies et.
                    textbf{sffamily And, we continue with more questions:}
                    begin{QA}[remember previous]
                    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                    end{QA}

                    textbf{sffamily And, Here is a new set of questions:}
                    begin{QA}
                    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                    question Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet
                    answer Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatib
                    end{QA}


                    end{document}


                    enter image description here



                    Notice that I use two counters here. One counter is essentially the list's counter for each item. If it's odd, that means I'm asking a question. If it's even, that means I'm answering a question. The second counter is only advanced once the question/answer pair has been established.



                    Also, notice that question and answer are stupid, in the sense that they're really just stand-ins for item and don't do much else. Everything is handled through item and tracking counters. I try to let the environment itself handle the tracking of questions and answers. The only difficulty comes when adding space. From within the {list} environment's arguments, not much can be done.



                    One thing to note, you cannot insert vspace{...} from within the first argument to the {list} environment. It will do nothing there and just be ignored for the most part (or show up where you don't expect it).







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Sep 11 '18 at 2:06

























                    answered Sep 11 '18 at 0:56









                    A.EllettA.Ellett

                    36.6k1169177




                    36.6k1169177























                        1














                        The space between items is controlled by itemsep, so you can fix for each item, with the advantage that your Q & A lists will not influenced by the default itemsep as it would happen using some additional vertical space as vspace,bigskip. I will add some glue too, not a fixed length, that would help to avoid orphan items/lines.



                        This can be done easily as already proposed making a macro for each item type, and I think that semantically is better that a complex redefine of item type to hiddenly switch from "Q." to "A.". With the "keep it simple" principle in mind, I do not see the need of conditionals or counters (I will edit the answer if you clarify this point), so the macros could be some like this:



                        documentclass{article}

                        newcommandQ[1]{item[bfseries Q.]
                        itemsep2pt plus 2pt #1}
                        newcommandA[1]{item[bfseries A.]
                        itemsep1em plus .2em minus .1em #1}

                        newenvironment{q-a}{section*{Questions
                        and answers}begin{itemize}}{end{itemize}}

                        begin{document}

                        begin{q-a}
                        Q Question 1
                        A Answer 1
                        Q Question 2
                        A Answer 2
                        Q Question 3
                        A Answer 3
                        end{q-a}

                        end{document}


                        mwe






                        share|improve this answer






























                          1














                          The space between items is controlled by itemsep, so you can fix for each item, with the advantage that your Q & A lists will not influenced by the default itemsep as it would happen using some additional vertical space as vspace,bigskip. I will add some glue too, not a fixed length, that would help to avoid orphan items/lines.



                          This can be done easily as already proposed making a macro for each item type, and I think that semantically is better that a complex redefine of item type to hiddenly switch from "Q." to "A.". With the "keep it simple" principle in mind, I do not see the need of conditionals or counters (I will edit the answer if you clarify this point), so the macros could be some like this:



                          documentclass{article}

                          newcommandQ[1]{item[bfseries Q.]
                          itemsep2pt plus 2pt #1}
                          newcommandA[1]{item[bfseries A.]
                          itemsep1em plus .2em minus .1em #1}

                          newenvironment{q-a}{section*{Questions
                          and answers}begin{itemize}}{end{itemize}}

                          begin{document}

                          begin{q-a}
                          Q Question 1
                          A Answer 1
                          Q Question 2
                          A Answer 2
                          Q Question 3
                          A Answer 3
                          end{q-a}

                          end{document}


                          mwe






                          share|improve this answer




























                            1












                            1








                            1







                            The space between items is controlled by itemsep, so you can fix for each item, with the advantage that your Q & A lists will not influenced by the default itemsep as it would happen using some additional vertical space as vspace,bigskip. I will add some glue too, not a fixed length, that would help to avoid orphan items/lines.



                            This can be done easily as already proposed making a macro for each item type, and I think that semantically is better that a complex redefine of item type to hiddenly switch from "Q." to "A.". With the "keep it simple" principle in mind, I do not see the need of conditionals or counters (I will edit the answer if you clarify this point), so the macros could be some like this:



                            documentclass{article}

                            newcommandQ[1]{item[bfseries Q.]
                            itemsep2pt plus 2pt #1}
                            newcommandA[1]{item[bfseries A.]
                            itemsep1em plus .2em minus .1em #1}

                            newenvironment{q-a}{section*{Questions
                            and answers}begin{itemize}}{end{itemize}}

                            begin{document}

                            begin{q-a}
                            Q Question 1
                            A Answer 1
                            Q Question 2
                            A Answer 2
                            Q Question 3
                            A Answer 3
                            end{q-a}

                            end{document}


                            mwe






                            share|improve this answer















                            The space between items is controlled by itemsep, so you can fix for each item, with the advantage that your Q & A lists will not influenced by the default itemsep as it would happen using some additional vertical space as vspace,bigskip. I will add some glue too, not a fixed length, that would help to avoid orphan items/lines.



                            This can be done easily as already proposed making a macro for each item type, and I think that semantically is better that a complex redefine of item type to hiddenly switch from "Q." to "A.". With the "keep it simple" principle in mind, I do not see the need of conditionals or counters (I will edit the answer if you clarify this point), so the macros could be some like this:



                            documentclass{article}

                            newcommandQ[1]{item[bfseries Q.]
                            itemsep2pt plus 2pt #1}
                            newcommandA[1]{item[bfseries A.]
                            itemsep1em plus .2em minus .1em #1}

                            newenvironment{q-a}{section*{Questions
                            and answers}begin{itemize}}{end{itemize}}

                            begin{document}

                            begin{q-a}
                            Q Question 1
                            A Answer 1
                            Q Question 2
                            A Answer 2
                            Q Question 3
                            A Answer 3
                            end{q-a}

                            end{document}


                            mwe







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Sep 11 '18 at 8:07

























                            answered Sep 11 '18 at 7:53









                            FranFran

                            53.4k6119183




                            53.4k6119183






























                                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%2f450319%2fspacing-between-groups-of-two-list-items%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?

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

                                Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents