Using table inside solution environment of exam documentclassProblem with redefining Tabular environment with...

What is this waxed root vegetable?

Reason why dimensional travelling would be restricted

Is my plan for fixing my water heater leak bad?

Where was Karl Mordo in Infinity War?

Is divide-by-zero a security vulnerability?

Did 5.25" floppies undergo a change in magnetic coating?

Do Hexblade warlocks choose their spells from the Hexblade spell list or the warlock spell list?

Test pad's ESD protection

my breadboard simulation doesn't work properly

Easy code troubleshooting in wordpress

How would we write a misogynistic character without offending people?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Make me a metasequence

What is a term for a function that when called repeatedly, has the same effect as calling once?

When was drinking water recognized as crucial in marathon running?

How do ISS astronauts "get their stripes"?

Hacker Rank: Array left rotation

Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?

Are small insurances worth it

Canadian citizen, on US no-fly list. What can I do in order to be allowed on flights which go through US airspace?

Wrap all numerics in JSON with quotes

Why is working on the same position for more than 15 years not a red flag?

Equivalent to "source" in OpenBSD?

Tcolorbox as an item in list environment



Using table inside solution environment of exam documentclass


Problem with redefining Tabular environment with the renewenvironment ‎command‎How to detect if in an exercise environment?Lost float in exam classUse column-separator & (ampersand) inside newenvironmentLost float in exam classSwitching between environmentsHow to make table floats work with preview/standalone environment?Constant Solution Spacing in the Exam DocumentclassTable issue inside a custom environmentTable (float) influenced by environmentTwo different versions for exam, solution file needs to have a figure. Float(s) lost error with current codeexam class 2.6: use self defined environment which depends on printanswers before first questionGrade table too long within exam document class













0















I am trying to use the table environment inside the solution environment of the exam documentclass. Unfortunately this doesnt work as stated in this question since table is also a float.




The solution environment internally uses a vbox and this has as a consequence that floats are not allowed inside this environment. Instead of using the floating environment table you can use a center environment




Since they work outside of the solution environment i am looking for a way to modify begin{table} ... end{table} to act as it is outside the solution and inside replaces itself with begin{center}...end{center}.



Fortunately as this post shows its easy to find out whether or not you are inside a solution environment. I tested this and it works.

However since the documents i have to adapt to the exam documentclass are numerous and are also used in other documentclasses I would ideally not create a new environment but adapt the table environments similar to what happend here to the figure or here to tabular environment. This is my code so far:
UPDATE: I dont know why, but with center instead of begin{center} the error is gone and also allows a way to tread the optional argument of table



documentclass{exam}

letoldtabletable
letendoldtableendtable

renewenvironment{table}[1][h]
{ifinner center else oldtable[#1] fi}
{ifinner endcenter else endoldtable fi}

begin{document}

begin{questions} %error is no question
printanswers

question{Question featuring a table environment}

begin{table}[h]
begin{tabular}{|ll|}
Question & in \
Question & part \
end{tabular}
end{table}


begin{solution}
Solution featuring a table environment

begin{table}[h]
begin{tabular}{|ll|}
Solution & in \
Solution & part \
end{tabular}
end{table}

end{solution}

end{questions}

end{document}


But I fear I am not handling the paramter of table correct, since this leads to the error: Unknown float option `['. begin{table}[



This solution works outside "inner" and can handle the optional argument of table, however if ifinner is true i get the error




Extra }, or forgotten endgroup. end{table}




Does anyone has a suggestion on how to adapt table based on the environment?



Thank you very much










share|improve this question




















  • 4





    As long as you don't use caption, you can use the center environment. If you need a caption, use captionof{table}{some caption}.

    – Bernard
    20 hours ago













  • Thanks! This is a solution i can use for future documents, yet i still need a way to handle the existing ones without changeging the table parts in them

    – Finn
    5 hours ago











  • In this case, another possibility is to use the ``[H]` placement specifier (defined by the float package), which can easily be done with Search and Replace in your editor.

    – Bernard
    2 hours ago
















0















I am trying to use the table environment inside the solution environment of the exam documentclass. Unfortunately this doesnt work as stated in this question since table is also a float.




The solution environment internally uses a vbox and this has as a consequence that floats are not allowed inside this environment. Instead of using the floating environment table you can use a center environment




Since they work outside of the solution environment i am looking for a way to modify begin{table} ... end{table} to act as it is outside the solution and inside replaces itself with begin{center}...end{center}.



Fortunately as this post shows its easy to find out whether or not you are inside a solution environment. I tested this and it works.

However since the documents i have to adapt to the exam documentclass are numerous and are also used in other documentclasses I would ideally not create a new environment but adapt the table environments similar to what happend here to the figure or here to tabular environment. This is my code so far:
UPDATE: I dont know why, but with center instead of begin{center} the error is gone and also allows a way to tread the optional argument of table



documentclass{exam}

letoldtabletable
letendoldtableendtable

renewenvironment{table}[1][h]
{ifinner center else oldtable[#1] fi}
{ifinner endcenter else endoldtable fi}

begin{document}

begin{questions} %error is no question
printanswers

question{Question featuring a table environment}

begin{table}[h]
begin{tabular}{|ll|}
Question & in \
Question & part \
end{tabular}
end{table}


begin{solution}
Solution featuring a table environment

begin{table}[h]
begin{tabular}{|ll|}
Solution & in \
Solution & part \
end{tabular}
end{table}

end{solution}

end{questions}

end{document}


But I fear I am not handling the paramter of table correct, since this leads to the error: Unknown float option `['. begin{table}[



This solution works outside "inner" and can handle the optional argument of table, however if ifinner is true i get the error




Extra }, or forgotten endgroup. end{table}




Does anyone has a suggestion on how to adapt table based on the environment?



Thank you very much










share|improve this question




















  • 4





    As long as you don't use caption, you can use the center environment. If you need a caption, use captionof{table}{some caption}.

    – Bernard
    20 hours ago













  • Thanks! This is a solution i can use for future documents, yet i still need a way to handle the existing ones without changeging the table parts in them

    – Finn
    5 hours ago











  • In this case, another possibility is to use the ``[H]` placement specifier (defined by the float package), which can easily be done with Search and Replace in your editor.

    – Bernard
    2 hours ago














0












0








0








I am trying to use the table environment inside the solution environment of the exam documentclass. Unfortunately this doesnt work as stated in this question since table is also a float.




The solution environment internally uses a vbox and this has as a consequence that floats are not allowed inside this environment. Instead of using the floating environment table you can use a center environment




Since they work outside of the solution environment i am looking for a way to modify begin{table} ... end{table} to act as it is outside the solution and inside replaces itself with begin{center}...end{center}.



Fortunately as this post shows its easy to find out whether or not you are inside a solution environment. I tested this and it works.

However since the documents i have to adapt to the exam documentclass are numerous and are also used in other documentclasses I would ideally not create a new environment but adapt the table environments similar to what happend here to the figure or here to tabular environment. This is my code so far:
UPDATE: I dont know why, but with center instead of begin{center} the error is gone and also allows a way to tread the optional argument of table



documentclass{exam}

letoldtabletable
letendoldtableendtable

renewenvironment{table}[1][h]
{ifinner center else oldtable[#1] fi}
{ifinner endcenter else endoldtable fi}

begin{document}

begin{questions} %error is no question
printanswers

question{Question featuring a table environment}

begin{table}[h]
begin{tabular}{|ll|}
Question & in \
Question & part \
end{tabular}
end{table}


begin{solution}
Solution featuring a table environment

begin{table}[h]
begin{tabular}{|ll|}
Solution & in \
Solution & part \
end{tabular}
end{table}

end{solution}

end{questions}

end{document}


But I fear I am not handling the paramter of table correct, since this leads to the error: Unknown float option `['. begin{table}[



This solution works outside "inner" and can handle the optional argument of table, however if ifinner is true i get the error




Extra }, or forgotten endgroup. end{table}




Does anyone has a suggestion on how to adapt table based on the environment?



Thank you very much










share|improve this question
















I am trying to use the table environment inside the solution environment of the exam documentclass. Unfortunately this doesnt work as stated in this question since table is also a float.




The solution environment internally uses a vbox and this has as a consequence that floats are not allowed inside this environment. Instead of using the floating environment table you can use a center environment




Since they work outside of the solution environment i am looking for a way to modify begin{table} ... end{table} to act as it is outside the solution and inside replaces itself with begin{center}...end{center}.



Fortunately as this post shows its easy to find out whether or not you are inside a solution environment. I tested this and it works.

However since the documents i have to adapt to the exam documentclass are numerous and are also used in other documentclasses I would ideally not create a new environment but adapt the table environments similar to what happend here to the figure or here to tabular environment. This is my code so far:
UPDATE: I dont know why, but with center instead of begin{center} the error is gone and also allows a way to tread the optional argument of table



documentclass{exam}

letoldtabletable
letendoldtableendtable

renewenvironment{table}[1][h]
{ifinner center else oldtable[#1] fi}
{ifinner endcenter else endoldtable fi}

begin{document}

begin{questions} %error is no question
printanswers

question{Question featuring a table environment}

begin{table}[h]
begin{tabular}{|ll|}
Question & in \
Question & part \
end{tabular}
end{table}


begin{solution}
Solution featuring a table environment

begin{table}[h]
begin{tabular}{|ll|}
Solution & in \
Solution & part \
end{tabular}
end{table}

end{solution}

end{questions}

end{document}


But I fear I am not handling the paramter of table correct, since this leads to the error: Unknown float option `['. begin{table}[



This solution works outside "inner" and can handle the optional argument of table, however if ifinner is true i get the error




Extra }, or forgotten endgroup. end{table}




Does anyone has a suggestion on how to adapt table based on the environment?



Thank you very much







floats environments exam






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago







Finn

















asked 20 hours ago









FinnFinn

1494




1494








  • 4





    As long as you don't use caption, you can use the center environment. If you need a caption, use captionof{table}{some caption}.

    – Bernard
    20 hours ago













  • Thanks! This is a solution i can use for future documents, yet i still need a way to handle the existing ones without changeging the table parts in them

    – Finn
    5 hours ago











  • In this case, another possibility is to use the ``[H]` placement specifier (defined by the float package), which can easily be done with Search and Replace in your editor.

    – Bernard
    2 hours ago














  • 4





    As long as you don't use caption, you can use the center environment. If you need a caption, use captionof{table}{some caption}.

    – Bernard
    20 hours ago













  • Thanks! This is a solution i can use for future documents, yet i still need a way to handle the existing ones without changeging the table parts in them

    – Finn
    5 hours ago











  • In this case, another possibility is to use the ``[H]` placement specifier (defined by the float package), which can easily be done with Search and Replace in your editor.

    – Bernard
    2 hours ago








4




4





As long as you don't use caption, you can use the center environment. If you need a caption, use captionof{table}{some caption}.

– Bernard
20 hours ago







As long as you don't use caption, you can use the center environment. If you need a caption, use captionof{table}{some caption}.

– Bernard
20 hours ago















Thanks! This is a solution i can use for future documents, yet i still need a way to handle the existing ones without changeging the table parts in them

– Finn
5 hours ago





Thanks! This is a solution i can use for future documents, yet i still need a way to handle the existing ones without changeging the table parts in them

– Finn
5 hours ago













In this case, another possibility is to use the ``[H]` placement specifier (defined by the float package), which can easily be done with Search and Replace in your editor.

– Bernard
2 hours ago





In this case, another possibility is to use the ``[H]` placement specifier (defined by the float package), which can easily be done with Search and Replace in your editor.

– Bernard
2 hours ago










1 Answer
1






active

oldest

votes


















0














I found a solution and posting it here as answer if someoneelse is facing this issue. The (in hindsight obvious) problem was that ifinner works in the beginning, because it is a floating environment, but as soon as table begins it is not anymore. Therefor the endcenter could no be reached. I have tried a few alternatives and found the easiest way is to define a custom boolean that checks if the ifinner of the modified table is reached and use this to set a boolean. On the endtablethis boolean can then be used to take care of ending it correctly.



letoldtabletable
letendoldtableendtable
newififinsidefloatingenv %set boolean for
insidefloatingenvfalse %not necessary but to be sure its false

renewenvironment{table}[1][h]
{ifinner center insidefloatingenvtrue else oldtable[#1] fi}
{ifinsidefloatingenv endcenter insidefloatingenvfalse else endoldtable fi}





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%2f477730%2fusing-table-inside-solution-environment-of-exam-documentclass%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I found a solution and posting it here as answer if someoneelse is facing this issue. The (in hindsight obvious) problem was that ifinner works in the beginning, because it is a floating environment, but as soon as table begins it is not anymore. Therefor the endcenter could no be reached. I have tried a few alternatives and found the easiest way is to define a custom boolean that checks if the ifinner of the modified table is reached and use this to set a boolean. On the endtablethis boolean can then be used to take care of ending it correctly.



    letoldtabletable
    letendoldtableendtable
    newififinsidefloatingenv %set boolean for
    insidefloatingenvfalse %not necessary but to be sure its false

    renewenvironment{table}[1][h]
    {ifinner center insidefloatingenvtrue else oldtable[#1] fi}
    {ifinsidefloatingenv endcenter insidefloatingenvfalse else endoldtable fi}





    share|improve this answer




























      0














      I found a solution and posting it here as answer if someoneelse is facing this issue. The (in hindsight obvious) problem was that ifinner works in the beginning, because it is a floating environment, but as soon as table begins it is not anymore. Therefor the endcenter could no be reached. I have tried a few alternatives and found the easiest way is to define a custom boolean that checks if the ifinner of the modified table is reached and use this to set a boolean. On the endtablethis boolean can then be used to take care of ending it correctly.



      letoldtabletable
      letendoldtableendtable
      newififinsidefloatingenv %set boolean for
      insidefloatingenvfalse %not necessary but to be sure its false

      renewenvironment{table}[1][h]
      {ifinner center insidefloatingenvtrue else oldtable[#1] fi}
      {ifinsidefloatingenv endcenter insidefloatingenvfalse else endoldtable fi}





      share|improve this answer


























        0












        0








        0







        I found a solution and posting it here as answer if someoneelse is facing this issue. The (in hindsight obvious) problem was that ifinner works in the beginning, because it is a floating environment, but as soon as table begins it is not anymore. Therefor the endcenter could no be reached. I have tried a few alternatives and found the easiest way is to define a custom boolean that checks if the ifinner of the modified table is reached and use this to set a boolean. On the endtablethis boolean can then be used to take care of ending it correctly.



        letoldtabletable
        letendoldtableendtable
        newififinsidefloatingenv %set boolean for
        insidefloatingenvfalse %not necessary but to be sure its false

        renewenvironment{table}[1][h]
        {ifinner center insidefloatingenvtrue else oldtable[#1] fi}
        {ifinsidefloatingenv endcenter insidefloatingenvfalse else endoldtable fi}





        share|improve this answer













        I found a solution and posting it here as answer if someoneelse is facing this issue. The (in hindsight obvious) problem was that ifinner works in the beginning, because it is a floating environment, but as soon as table begins it is not anymore. Therefor the endcenter could no be reached. I have tried a few alternatives and found the easiest way is to define a custom boolean that checks if the ifinner of the modified table is reached and use this to set a boolean. On the endtablethis boolean can then be used to take care of ending it correctly.



        letoldtabletable
        letendoldtableendtable
        newififinsidefloatingenv %set boolean for
        insidefloatingenvfalse %not necessary but to be sure its false

        renewenvironment{table}[1][h]
        {ifinner center insidefloatingenvtrue else oldtable[#1] fi}
        {ifinsidefloatingenv endcenter insidefloatingenvfalse else endoldtable fi}






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 13 mins ago









        FinnFinn

        1494




        1494






























            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%2f477730%2fusing-table-inside-solution-environment-of-exam-documentclass%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

            El tren de la libertad Índice Antecedentes "Porque yo decido" Desarrollo de la...

            Castillo d'Acher Características Menú de navegación

            Connecting two nodes from the same mother node horizontallyTikZ: What EXACTLY does the the |- notation for...